Skip to content

Commit

Permalink
[major] Remove WebSocket.createServer() and WebSocket.connect()
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Dec 7, 2016
1 parent 22d3b77 commit 9922731
Showing 1 changed file with 5 additions and 39 deletions.
44 changes: 5 additions & 39 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,10 @@
* MIT Licensed
*/

var WS = module.exports = require('./lib/WebSocket');
const WebSocket = require('./lib/WebSocket');

WS.Server = require('./lib/WebSocketServer');
WS.Sender = require('./lib/Sender');
WS.Receiver = require('./lib/Receiver');
WebSocket.Server = require('./lib/WebSocketServer');
WebSocket.Receiver = require('./lib/Receiver');
WebSocket.Sender = require('./lib/Sender');

/**
* Create a new WebSocket server.
*
* @param {Object} options Server options
* @param {Function} fn Optional connection listener.
* @returns {WS.Server}
* @api public
*/
WS.createServer = function createServer (options, fn) {
var server = new WS.Server(options);

if (typeof fn === 'function') {
server.on('connection', fn);
}

return server;
};

/**
* Create a new WebSocket connection.
*
* @param {String} address The URL/address we need to connect to.
* @param {Function} fn Open listener.
* @returns {WS}
* @api public
*/
WS.connect = WS.createConnection = function connect (address, fn) {
var client = new WS(address);

if (typeof fn === 'function') {
client.on('open', fn);
}

return client;
};
module.exports = WebSocket;

0 comments on commit 9922731

Please sign in to comment.