code: function ondata(chunk) {
      packet.push(chunk);
      if (packet.isReady()) {
        if (self._state.sessionId !== packet.header.sessionId) {
          self._state.sessionId = packet.header.sessionId;
          self._state.packetCount = -1;
        }
        var buffer = packet.getData();
        packet.clear();
        var cb = self._state.receive;
        self._state.receive = undefined;
        self._state.messageType = undefined;
        self.receive(buffer, cb);
      }
    }
docs: register listerners on socket