sendPacket method
void
sendPacket(
- dynamic type, {
- dynamic data,
- dynamic options,
- dynamic callback,
Sends a packet.
Implementation
void sendPacket(type, {data, options, callback}) {
options = options ?? {};
options['compress'] = false != options['compress'];
if ('closing' != readyState && 'closed' != readyState) {
// _logger.fine('sending packet "%s" (%s)', type, data);
var packet = {'type': type, 'options': options};
if (data != null) packet['data'] = data;
// exports packetCreate event
emit('packetCreate', packet);
writeBuffer.add(packet);
// add send callback to object, if defined
if (callback != null) packetsFn.add(callback);
flush();
}
}