Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove WebSocket.createServer() and WebSocket.connect() #926

Merged
merged 1 commit into from Dec 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 6 additions & 40 deletions index.js
@@ -1,49 +1,15 @@
'use strict';

/*!
* ws: a node.js websocket client
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
* MIT Licensed
*/

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

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

/**
* 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;
};
'use strict';

/**
* 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);
const WebSocket = require('./lib/WebSocket');

if (typeof fn === 'function') {
client.on('open', fn);
}
WebSocket.Server = require('./lib/WebSocketServer');
WebSocket.Receiver = require('./lib/Receiver');
WebSocket.Sender = require('./lib/Sender');

return client;
};
module.exports = WebSocket;