How to use the faye.Client 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 GMOD / jbrowse / node / add-track-json.js View on Github external
}
	    trackListJson.tracks = newTracks
	})

	// write the new track list
	var trackListOutputData = JSON.stringify (trackListJson, null, 2)
	if (opt.options.stdout) {
	    process.stdout.write (trackListOutputData + "\n")
	} else {
	    fs.writeFileSync (trackListPath, trackListOutputData)
	}

	// publish notifications
	var publishUrl = opt.options['notify']
	if (publishUrl) {
	    var client = new faye.Client (publishUrl)
	    var secret = opt.options['secret']
	    if (secret)
		client.addExtension({
		    outgoing: function(message, callback) {
			message.ext = message.ext || {};
			message.ext.password = secret;
			callback(message);
		    }
		});

	    if (logging)
		client.addExtension({
		    outgoing: function(message, callback) {
			console.log ('client outgoing', message);
			callback(message);
		    }
github BBGInnovate / Sports-Data-Application-Suite / sportsdataprovider / FayeService.js View on Github external
*					with interacting with the Faye Server.
 * @author 			John Allen 
 * @version 		1.0.0
 * @module 			FayeService.js
 */

/* *************************** Required Classes **************************** */
var faye = require('faye');
var Config = require('./Config');
var util = require('util');
var log = require('./Logger.js');

/* *************************** Constructor Code **************************** */
var config = Config.getConfig();

var fayClient = new faye.Client(config.faye.url);

// we need to send the password to the server so lets add an extension to do
// this.
fayClient.addExtension({
	outgoing: function( message, callback ) {

		message.ext = message.ext || {};
		message.ext.password = config.faye.publishPassword;

		callback( message );
	}
});


/* *************************** Public Methods ****************************** */
/**
github jsforce / jsforce / lib / api / streaming.js View on Github external
Streaming.prototype._createClient = function(forChannelName, extensions) {
  // forChannelName is advisory, for an API workaround. It does not restrict or select the channel.
  var needsReplayFix = typeof forChannelName === 'string' && forChannelName.indexOf('/u/') === 0;
  var endpointUrl = [
    this._conn.instanceUrl,
    // special endpoint "/cometd/replay/xx.x" is only available in 36.0.
    // See https://releasenotes.docs.salesforce.com/en-us/summer16/release-notes/rn_api_streaming_classic_replay.htm
    "cometd" + (needsReplayFix === true && this._conn.version === "36.0" ? "/replay" : ""),
    this._conn.version
  ].join('/');
  var fayeClient = new Faye.Client(endpointUrl, {});
  fayeClient.setHeader('Authorization', 'OAuth '+this._conn.accessToken);
  if (extensions instanceof Array) {
    extensions.forEach(function(extension) {
      fayeClient.addExtension(extension);
    });
  }
  if (fayeClient._dispatcher.getConnectionTypes().indexOf('callback-polling') === -1) {
    // prevent streaming API server error
    fayeClient._dispatcher.selectTransport('long-polling');
    fayeClient._dispatcher._transport.batching = false;
  }
  return fayeClient;
};
github GMOD / jbrowse / node / test-delete-track.js View on Github external
#!/usr/bin/env node

var http = require('http'),
    faye = require('faye'),
    serverPath = process.argv[2] || '/faye',
    serverPort = process.argv[3] || 8000

var client = new faye.Client('http://localhost:' + serverPort + serverPath);

client.publish ("/tracks/delete",
		[ { "label" : "fromfaye" } ])
    .then (function() {
	console.log ("Sent /tracks/delete message")
	process.exit()
    })
github GMOD / jbrowse / node / test-alert.js View on Github external
#!/usr/bin/env node

var http = require('http'),
    faye = require('faye'),
    serverPath = process.argv[2] || '/faye',
    serverPort = process.argv[3] || 8000

var client = new faye.Client('http://localhost:' + serverPort + serverPath);

client.publish ("/alert", "Watch out for rogue messages!")
    .then (function() {
	process.exit()
    })
github jsforce / jsforce / build / jsforce-api-streaming.js View on Github external
Streaming.prototype._createClient = function() {
  var endpointUrl = [ this._conn.instanceUrl, "cometd", this._conn.version ].join('/');
  var fayeClient = new Faye.Client(endpointUrl, {});
  fayeClient.setHeader('Authorization', 'OAuth '+this._conn.accessToken);
  return fayeClient;
};
github yue / node-gui / client / protocol.js View on Github external
function Protocol (address) {
    this.bayeux = new faye.Client (address);
}
github M6Web / websocket-bench / lib / workers / fayeworker.js View on Github external
FayeWorker.prototype.createClient = function (callback) {

  var faye = require('faye');
  var _this = this;

  var client = new faye.Client(this.server);

  if (_this.generator.beforeConnect) {
    _this.generator.beforeConnect(client);
  }

  client.bind('transport:down', function () {
    callback(true, client);
  });

  client.bind('transport:up', function () {
    callback(false, client);
  });

  client.connect();
};
github ctubio / Krypto-trading-bot / atlasats.ts View on Github external
constructor(config : IConfigProvider) {
            this._secret = config.GetString("AtlasAtsSecret");
            this._token = config.GetString("AtlasAtsMultiToken");
            this._client = new Faye.Client(url.resolve(config.GetString("AtlasAtsHttpUrl"), '/api/v1/streaming'), {
                endpoints: {
                    websocket: config.GetString("AtlasAtsWsUrl")
                }
            });

            this._client.addExtension({
                outgoing: (msg, cb) => {
                    if (msg.channel != '/meta/handshake') {
                        msg.ext = this.signMessage(msg.channel, msg);
                    }
                    cb(msg);
                },
                incoming: (msg, cb) => {
                    if (msg.hasOwnProperty('successful') && !msg.successful) {
                        this._log("UNSUCCESSFUL %o", msg);
                    }
github SoraSuegami / Vreath / wallet / client / index.ts View on Github external
refresh_invalids(num:number){
        this._invalids = num;
    }
    async looping(bool:boolean){
        this._loop_mode = bool;
        if(bool===true) await start();
    }
}

let db:any;
let store:Store;

const port = peer_list[0].port || "57750";
const ip = peer_list[0].ip || "localhost";

const client = new faye.Client('http://'+ip+':'+port+'/pubsub');
const socket = io.connect('http://'+ip+':'+port);


client.subscribe('/data',async (data:Data)=>{
    if(data.type==="block"){
        store.push_yet_data(data);
        return 0;
    }
    const unit_amount = await get_balance(store.unit_address,store);
    if(data.type==="tx"&&unit_amount>0) store.push_yet_data(data);
    //setImmediate(compute_tx);
    return 0;
});

socket.on('replacechain',async (chain:T.Block[])=>{
    if(!store.replace_mode) await check_chain(chain,store.chain,store.pool,store);

faye

Simple pub/sub messaging for the web

Apache-2.0
Latest version published 4 years ago

Package Health Score

76 / 100
Full package analysis