Sha256: 175a623959570b0dbbfafbb5ab73014d55d360cf51f29ccb640212e1e2e94b86

Contents?: true

Size: 1.28 KB

Versions: 22

Compression:

Stored size: 1.28 KB

Contents

// API references:
//
// * https://html.spec.whatwg.org/multipage/comms.html#network
// * https://dom.spec.whatwg.org/#interface-eventtarget
// * https://dom.spec.whatwg.org/#interface-event

'use strict';

var util   = require('util'),
    driver = require('websocket-driver'),
    API    = require('./websocket/api');

var WebSocket = function(request, socket, body, protocols, options) {
  options = options || {};

  this._stream = socket;
  this._driver = driver.http(request, {maxLength: options.maxLength, protocols: protocols});

  var self = this;
  if (!this._stream || !this._stream.writable) return;
  if (!this._stream.readable) return this._stream.end();

  var catchup = function() { self._stream.removeListener('data', catchup) };
  this._stream.on('data', catchup);

  API.call(this, options);

  process.nextTick(function() {
    self._driver.start();
    self._driver.io.write(body);
  });
};
util.inherits(WebSocket, API);

WebSocket.isWebSocket = function(request) {
  return driver.isWebSocket(request);
};

WebSocket.validateOptions = function(options, validKeys) {
  driver.validateOptions(options, validKeys);
};

WebSocket.WebSocket   = WebSocket;
WebSocket.Client      = require('./websocket/client');
WebSocket.EventSource = require('./eventsource');

module.exports        = WebSocket;

Version data entries

22 entries across 21 versions & 9 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
disco_app-0.18.0 test/dummy/node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
disco_app-0.18.2 test/dummy/node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
tang-0.2.1 spec/tang_app/node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/faye-websocket/lib/faye/websocket.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/faye-websocket/lib/faye/websocket.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/faye-websocket/lib/faye/websocket.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/faye-websocket/lib/faye/websocket.js
tang-0.2.0 spec/tang_app/node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
tang-0.1.0 spec/tang_app/node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
tang-0.0.9 spec/tang_app/node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
enju_library-0.3.8 spec/dummy/node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
ilog-0.4.1 node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
ilog-0.4.0 node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
ilog-0.3.3 node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
jester-data-8.0.0 node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
ezii-os-5.2.1 node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
ezii-os-2.0.1 node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
ezii-os-1.1.0 node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js
ezii-os-1.0.0 node_modules/sockjs-client/node_modules/faye-websocket/lib/faye/websocket.js