broadcast method

Future<void> broadcast({
  1. required String body,
  2. String? contentType,
  3. Map<String, String>? headers,
})

Broadcasts a message to all connected clients

Implementation

Future<void> broadcast({
  required String body,
  String? contentType,
  Map<String, String>? headers,
}) async {
  for (final connection in connections) {
    // Send to a special broadcast destination for each client
    await sendToDestination(
      destination: '/broadcast/${connection.sessionId}',
      body: body,
      contentType: contentType,
      headers: headers,
    );
  }
}