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. Of a copy of
// the clients, as one may disconnect while a filter runs.
for (var client in List.of(_clients)) {
dynamic result = true;
if (filter != null) {
result = await filter(client);
}
if (result == true && !client._closed) {
client.channel.sink.add((serializer ?? json.encode)(event.toJson()));
}
}
if (synchronizationChannel != null && notify != false) {
synchronizationChannel!.sink.add(event);
}
}