batchEvent method
Future<void>
batchEvent(
- WebSocketEvent event, {
- dynamic filter(
- WebSocketContext socket
- bool notify = true,
Slates an event to be dispatched.
Implementation
Future<void> batchEvent(WebSocketEvent event,
{Function(WebSocketContext socket)? filter, bool notify = true}) async {
// Default implementation will just immediately fire events
for (var client in _clients) {
dynamic result = true;
if (filter != null) {
result = await filter(client);
}
if (result == true) {
client.channel.sink.add((serializer ?? json.encode)(event.toJson()));
}
}
if (synchronizationChannel != null && notify != false) {
synchronizationChannel!.sink.add(event);
}
}