onevent method

void onevent(
  1. Map packet
)

Called upon a server event.

@param {Object} packet @api private

Implementation

void onevent(Map packet) {
  List args = packet['data'] ?? [];
//    debug('emitting event %j', args);

  if (null != packet['id']) {
//      debug('attaching ack callback to event');
    args.add(ack(packet['id']));
  }

  // dart doesn't support "String... rest" syntax.
  if (connected == true) {
    if (args.length > 2) {
      Function.apply(super.emit, [args.first, args.sublist(1)]);
    } else {
      Function.apply(super.emit, args);
    }
  } else {
    receiveBuffer.add(args);
  }
}