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