sendToUsers method

  1. @override
void sendToUsers(
  1. List userIds,
  2. String event,
  3. dynamic data
)
override

Send a message to multiple specific users (by user IDs). The adapter is responsible for mapping user IDs to client ID(s).

Implementation

@override
void sendToUsers(List<dynamic> userIds, String event, dynamic data) {
  if (userIds.isEmpty) return;

  // Deduplicate userIds and collect valid clients
  final uniqueUserIds = userIds.toSet();
  final clientsToSend = <SocketClient>[];

  for (final userId in uniqueUserIds) {
    final clientId = _userClientMap[userId];
    if (clientId != null) {
      final client = _clients[clientId];
      if (client != null) {
        clientsToSend.add(client);
      }
    }
  }

  // Send to all collected clients
  for (final client in clientsToSend) {
    client.send(event, data);
  }
}