You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
815 B

  1. /*!
  2. * ws: a node.js websocket client
  3. * Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
  4. * MIT Licensed
  5. */
  6. module.exports = require('./lib/WebSocket');
  7. module.exports.Server = require('./lib/WebSocketServer');
  8. module.exports.Sender = require('./lib/Sender');
  9. module.exports.Receiver = require('./lib/Receiver');
  10. module.exports.createServer = function (options, connectionListener) {
  11. var server = new module.exports.Server(options);
  12. if (typeof connectionListener === 'function') {
  13. server.on('connection', connectionListener);
  14. }
  15. return server;
  16. };
  17. module.exports.connect = module.exports.createConnection = function (address, openListener) {
  18. var client = new module.exports(address);
  19. if (typeof openListener === 'function') {
  20. client.on('open', openListener);
  21. }
  22. return client;
  23. };