socketioconnection.js 578 B

1234567891011121314151617181920212223
  1. var io = require('socket.io-client');
  2. function SocketIoConnection(config) {
  3. this.connection = io.connect(config.url, config.socketio);
  4. }
  5. SocketIoConnection.prototype.on = function (ev, fn) {
  6. this.connection.on(ev, fn);
  7. };
  8. SocketIoConnection.prototype.emit = function () {
  9. this.connection.emit.apply(this.connection, arguments);
  10. };
  11. SocketIoConnection.prototype.getSessionid = function () {
  12. return this.connection.id;
  13. };
  14. SocketIoConnection.prototype.disconnect = function () {
  15. return this.connection.disconnect();
  16. };
  17. module.exports = SocketIoConnection;