aboutsummaryrefslogtreecommitdiffstats
path: root/signaling-server/node_modules/socket.io/lib/transports/websocket.js
blob: 78a43043d5fa0433637d373329339ead436b3947 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*!
 * socket.io-node
 * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
 * MIT Licensed
 */

/**
 * Module requirements.
 */

var protocolVersions = require('./websocket/');

/**
 * Export the constructor.
 */

exports = module.exports = WebSocket;

/**
 * HTTP interface constructor. Interface compatible with all transports that
 * depend on request-response cycles.
 *
 * @api public
 */

function WebSocket (mng, data, req) {
  var transport
    , version = req.headers['sec-websocket-version'];
  if (typeof version !== 'undefined' && typeof protocolVersions[version] !== 'undefined') {
    transport = new protocolVersions[version](mng, data, req);
  }
  else transport = new protocolVersions['default'](mng, data, req);
  if (typeof this.name !== 'undefined') transport.name = this.name;
  return transport;
};