Sha256: 9c1d0471b2c16f471abecc1c43f02f56cef4f9554c2da6d3069581eede288daa

Contents?: true

Size: 1.36 KB

Versions: 13

Compression:

Stored size: 1.36 KB

Contents

'use strict';

// Protocol references:
// 
// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75
// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76
// * http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17

var Base   = require('./driver/base'),
    Client = require('./driver/client'),
    Server = require('./driver/server');

var Driver = {
  client: function(url, options) {
    options = options || {};
    if (options.masking === undefined) options.masking = true;
    return new Client(url, options);
  },

  server: function(options) {
    options = options || {};
    if (options.requireMasking === undefined) options.requireMasking = true;
    return new Server(options);
  },

  http: function() {
    return Server.http.apply(Server, arguments);
  },

  isSecureRequest: function(request) {
    return Server.isSecureRequest(request);
  },

  isWebSocket: function(request) {
    if (request.method !== 'GET') return false;

    var connection = request.headers.connection || '',
        upgrade    = request.headers.upgrade || '';

    return request.method === 'GET' &&
           connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 &&
           upgrade.toLowerCase() === 'websocket';
  },

  validateOptions: function(options, validKeys) {
    Base.validateOptions(options, validKeys);
  }
};

module.exports = Driver;

Version data entries

13 entries across 13 versions & 7 rubygems

Version Path
tang-0.2.1 spec/tang_app/node_modules/sockjs/node_modules/websocket-driver/lib/websocket/driver.js
tang-0.2.0 spec/tang_app/node_modules/sockjs/node_modules/websocket-driver/lib/websocket/driver.js
tang-0.1.0 spec/tang_app/node_modules/sockjs/node_modules/websocket-driver/lib/websocket/driver.js
tang-0.0.9 spec/tang_app/node_modules/sockjs/node_modules/websocket-driver/lib/websocket/driver.js
blsk-sevcore-0.0.2 blsk_old/bluesky-doc/bluesky-doc/node_modules/websocket-driver/lib/websocket/driver.js
optimacms-0.4.3 spec/dummy/node_modules/websocket-driver/lib/websocket/driver.js
optimacms-0.4.2 spec/dummy/node_modules/websocket-driver/lib/websocket/driver.js
cortex-0.1.3 spec/dummy/node_modules/websocket-driver/lib/websocket/driver.js
dragonfly_puppeteer-0.1.0 node_modules/websocket-driver/lib/websocket/driver.js
lanes-0.8.0 node_modules/websocket-driver/lib/websocket/driver.js
gulp_assets-1.0.0.pre.5 template/node_modules/gulp-livereload/node_modules/tiny-lr/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver.js
gulp_assets-1.0.0.pre.4 template/node_modules/gulp-livereload/node_modules/tiny-lr/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-livereload/node_modules/tiny-lr/node_modules/faye-websocket/node_modules/websocket-driver/lib/websocket/driver.js