onMessage method

  1. @override
void onMessage(
  1. Uint8List data, [
  2. Channel channel = kAnyChannel
])
override

Implementation

@override
void onMessage(Uint8List data, [Channel channel = kAnyChannel]) {
  super.onMessage(data);
  final packet = decode(data);
  final receiver = packet.channel;
  final newPacket = packet.withChannel(channel);
  if (validate &&
      !isValidCall(newPacket.function, receiver, newPacket.channel)) {
    return;
  }
  if (!(filter?.call(newPacket, receiver) ?? false)) {
    return;
  }
  if (newPacket.channel == kAuthorityChannel) {
    runFunction(newPacket);
    return;
  }
  sendMessage(newPacket);
}