Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.attach = function attach(server, next) {
var faye = new Faye.NodeAdapter({ mount: '/faye' });
if (process.env.FAYE_LOGLEVEL) {
// This produces lots of logs, which are usefull
// only during development of RT things.
// USAGE: FAYE_LOGLEVEL=info ./fontello.js server
Faye.Logging.logLevel = process.env.FAYE_LOGLEVEL;
}
// FIXME: Replace dummy active_clients inc/dec with real heartbeat/timeouts
faye.bind('handshake', function () { module.exports.activeClients++; });
faye.bind('disconnect', function () { module.exports.activeClients--; });
var curr_users_count = 0;
setInterval(function () {
if (module.exports.activeClients !== curr_users_count) {
curr_users_count = module.exports.activeClients;
faye.getClient().publish('/stats/users_online', curr_users_count);
}
}, 10000);
faye.attach(server);
next();
module.exports.attach = function attach(server, next) {
var faye = new Faye.NodeAdapter({ mount: '/faye' });
if (process.env.FAYE_LOGLEVEL) {
// This produces lots of logs, which are usefull
// only during development of RT things.
// USAGE: FAYE_LOGLEVEL=info ./fontello.js server
Faye.Logging.logLevel = process.env.FAYE_LOGLEVEL;
}
faye.attach(server);
next();
};
/*
* Author: Felix Kaser
* Copyright (c) 2011, Mayflower GmbH
* All rights reserved.
*
* This software is distributed under the BSD 3-clause
* license. The full license can be found in ../LICENSE.
*/
var http = require("http"),
faye = require("faye"),
authenticator = require("./authenticator");
// log all warnings
faye.Logging.logLevel = 'warn';
// create new faye node
var bayeux = new faye.NodeAdapter({
mount: "/faye",
timeout: 45
});
var serverAuth = {
incoming: function(message, callback) {
var closure = function(authenticated, cause) {
var auth = message.ext && message.ext.auth;
if (!authenticated) {
cause = cause || 'no reason specified';
faye.Logging.log(['message on ' + message.channel + ' not authenticated: ' + cause + " auth: " + auth], 'info');
message.error = 'Not authenticated: ' + cause;
} else {
var closure = function(authenticated, cause) {
var auth = message.ext && message.ext.auth;
if (!authenticated) {
cause = cause || 'no reason specified';
faye.Logging.log(['message on ' + message.channel + ' not authenticated: ' + cause + " auth: " + auth], 'info');
message.error = 'Not authenticated: ' + cause;
} else {
faye.Logging.log(['message on ' + message.channel + ' successfully authenticated: ' + auth], 'info');
}
callback(message);
};