onpacket method

void onpacket(
  1. dynamic packet
)

Called with socket packet.

@param {Object} packet @api private

Implementation

void onpacket(packet) {
  if (packet['nsp'] != nsp) return;

  switch (packet['type']) {
    case CONNECT:
      onconnect();
      break;

    case EVENT:
      onevent(packet);
      break;

    case BINARY_EVENT:
      onevent(packet);
      break;

    case ACK:
      onack(packet);
      break;

    case BINARY_ACK:
      onack(packet);
      break;

    case DISCONNECT:
      ondisconnect();
      break;

    case ERROR:
      emit('error', packet['data']);
      break;
  }
}