How to use the faye-websocket function in faye-websocket

To help you get started, we’ve selected a few faye-websocket 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 taggon / livereload / lib / server.js View on Github external
this.app.on('upgrade', (request, socket, body) => {
      if (!WebSocket.isWebSocket(request)) return;
      var ws = new WebSocket(request, socket, body);

      ws.on('message', event => {
        var data = event.data, json;
        try {
          json = JSON.parse(event.data);
          if (typeof json.command === 'string') {
            this.handleCommand(json);
          }
        } catch(e) { }
      });

      ws.on('close', event => {
        this.sockets = this.sockets.filter( sock => (sock !== ws) );
        ws = null;
      });
github mklabs / tiny-lr / lib / client.js View on Github external
constructor (req, socket, head, options = {}) {
    super();
    this.options = options;
    this.ws = new WebSocket(req, socket, head);
    this.ws.onmessage = this.message.bind(this);
    this.ws.onclose = this.close.bind(this);
    this.id = this.uniqueId('ws');
  }

faye-websocket

Standards-compliant WebSocket server and client

Apache-2.0
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis