How to use the faye.NodeAdapter function in faye

To help you get started, we’ve selected a few faye examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opitzconsulting / phonegap-proxy / server.js View on Github external
// ------------------
// Setup
// ------------------
var express = require('express');
var app = express();
var http = require('http');
var faye = require('faye');

app.use(express.static(__dirname));

var server = http.createServer(app);
var bayeux = new faye.NodeAdapter({mount: '/faye', timeout: 45});
bayeux.attach(server);



var port = 9000;
server.listen(port);
console.log("listening on port "+port);
github Jonovono / spotluck / lib / server.js View on Github external
var http = require('http'),
    faye = require('faye');

var redis = require("redis"),
    client = redis.createClient();

client.on("error", function(err) {
  console.log("Error " + err);
});

var bayeux = new faye.NodeAdapter({mount: '/faye', timeout: 45});

function sendUpdate(channel, num) {
  console.log('Sending update ' + channel + ' of num ' + num);
  var ev = {}
  ev.event = 'stat';
  ev.count = parseInt(num);
  bayeux.getClient().publish(channel, ev)
}

// Handle non-Bayeux requests
var server = http.createServer(function(request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello, non-Bayeux request');
});

bayeux.on('subscribe', function(clientId, channel) {
github GMOD / jbrowse / node / message-server.js View on Github external
])              // create Getopt instance
.bindHelp()     // bind option 'help' to default action
.parseSystem(); // parse command line

var serverPath = opt.options['root'] || '/faye';
var serverPort = opt.options['port'] || 8000;
var serverTimeout = opt.options['timeout'] || 45;
var logging = opt.options['messages'];

if (serverPath[0] != '/') {
    serverPath = '/' + serverPath
}

// Start faye server
var server = http.createServer(),
    bayeux = new faye.NodeAdapter({mount: serverPath, timeout: serverTimeout});

var secret = opt.options['secret']
if (secret)
    bayeux.addExtension({
	incoming: function(message, callback) {
	    if (message.channel.match(/^\/(tracks|alert|log)/)) {
		var password = message.ext && message.ext.password;
		if (password !== secret)
		    message.error = '403::Password required';
	    }
	    callback(message);
	},

	outgoing: function(message, callback) {
	    if (message.ext)
		delete message.ext.password;
github nodeca / nodeca.core / lib / autoload / hooks / init / faye.js View on Github external
function initFaye() {
    // Parse redis url
    let redisConfig = redisUrl.parse((N.config.database || {}).redis);

    // Init adapter
    let bayeux = new faye.NodeAdapter({
      mount: '/io/live',
      timeout: 10000,
      ping: 25000,
      engine: {
        type: fayeRedis,
        host: redisConfig.hostname,
        port: redisConfig.port,
        password: redisConfig.password,
        database: redisConfig.database,
        namespace: 'nodeca'
      }
    });

    // Add WebSocket server
    bayeux.addWebsocketExtension(deflate);
github BBGInnovate / Sports-Data-Application-Suite / sportsfayserver / server.js View on Github external
/** 
 * @fileOverview 	I am the Faye Messaging Server.
 * @author 			John Allen 
 * @version 		1.0.0
 * @module 			server.js
 */

/* *************************** Required Classes **************************** */
var http = require('http');
var https = require('https');
var faye = require('faye');
var fs = require('fs');

/* *************************** Constructor Code **************************** */
var bayeux = new faye.NodeAdapter({mount: '/faye', timeout: 45});

var secret = '78654323MyVeryL0ngStr1ngTh4tIsC00l4ndYouC4ntT0uchThi5IfY0uTry9907654';

// by default we will ALWAYS run under SSL
var runUnderSSL = false;

// if in dev (local) start the server this way: node server.js false
if (process.argv[2] !== undefined && process.argv[2] === 'false'){
	runUnderSSL = false;
}

// launch using SSL...
if( runUnderSSL ){

	var options = {
	  key: fs.readFileSync('/etc/apache2/SSL/soccer-epl-home.voanews.com.key'),
github logv / snorkel / snorkel / node_modules / superfluous / node_modules / primus.io / node_modules / primus / transformers / faye / server.js View on Github external
module.exports = function server() {
  var faye = require('faye')
    , primus = this.primus
    , Spark = this.Spark;

  this.service = new faye.NodeAdapter({
      mount: primus.pathname
    , timeout: 45
  });

  //
  // We've received a new connection, create a new Spark. The Spark will
  // automatically announce it self as a new connection once it's created (after
  // the next tick).
  //
  this.service.on('connection', function connection(socket) {
    var spark = new Spark(
        socket.handshake.headers  // HTTP request headers.
      , socket.handshake.address  // IP address.
      , socket.handshake.query    // Optional query string.
      , socket.id                 // Unique connection id
    );
github krakatoa / node_zmq_workshop / 05.1_health_check / faye.js View on Github external
var zmq = require('zmq'),
  http = require('http'),
  faye = require('faye');

var subscriber = zmq.socket('sub');

var host = '127.0.0.1';
var port = process.argv[2] || 8000;

subscriber.connect("tcp://127.0.0.1:4101");
subscriber.connect("tcp://127.0.0.1:4102");

var bayeux = new faye.NodeAdapter({
  mount: '/faye',
  timeout: 45
});

subscriber.subscribe('');

subscriber.on('message', function(msg) {
  console.log('read: ' + msg.toString());
  
  var json_msg = JSON.parse(msg.toString());
  bayeux.getClient().publish('/foo', {'status': json_msg});
});

bayeux.listen(port);
github soyuka / explorer / lib / socket.js View on Github external
module.exports = function(server, app) {
  var bayeux = new faye.NodeAdapter({mount: '/socket', timeout: 45})
  bayeux.attach(server)

  var users = app.get('users')
  var config = app.get('config')

  var hmac   = crypto.createHmac('sha256', config.session_secret);
  var token  = hmac.update('internal').digest('hex');

  bayeux.addExtension({
    incoming: function(message, callback) {

      if(!message.channel.match(/^\/meta\//)) {
        //internal message
        if(message.ext && message.ext.key === token)
          return callback(message)
github yue / node-gui / server / protocol.js View on Github external
function Protocol () {
    this.bayeux = new faye.NodeAdapter ({
	   	mount: config.listenUri,
	   	timeout: 45
   	});
}

faye

Simple pub/sub messaging for the web

Apache-2.0
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis