code: function(id, socket, adaptor) {
    EventEmitter.call(this);
    this.id = id;
    this.socket = socket;
    this.remoteAddress = {
      ip: socket.stream.remoteAddress,
      port: socket.stream.remotePort
    };
    this.adaptor = adaptor;
  
    var self = this;
  
    socket.on('close', this.emit.bind(this, 'disconnect'));
    socket.on('error', this.emit.bind(this, 'disconnect'));
    socket.on('disconnect', this.emit.bind(this, 'disconnect'));
  
    socket.on('pingreq', function(packet) {
      socket.pingresp();
    });
  
    socket.on('subscribe', this.adaptor.onSubscribe.bind(this.adaptor, this));
  
    socket.on('publish', this.adaptor.onPublish.bind(this.adaptor, this));
  
    this.state = ST_INITED;
  
    // TODO: any other events?
  }
docs: Socket class that wraps socket and websocket to provide unified interface for up level.