sendEvent method

Future<SendEventResponse> sendEvent({
  1. required String eventName,
  2. required String roomIdentifier,
  3. Map<String, String>? attributes,
})

Sends an event to a room. Use this within your application’s business logic to send events to clients of a room; e.g., to notify clients to change the way the chat UI is rendered.

May throw AccessDeniedException. May throw PendingVerification. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter eventName : Application-defined name of the event to send to clients.

Parameter roomIdentifier : Identifier of the room to which the event will be sent. Currently this must be an ARN.

Parameter attributes : Application-defined metadata to attach to the event sent to clients. The maximum length of the metadata is 1 KB total.

Implementation

Future<SendEventResponse> sendEvent({
  required String eventName,
  required String roomIdentifier,
  Map<String, String>? attributes,
}) async {
  final $payload = <String, dynamic>{
    'eventName': eventName,
    'roomIdentifier': roomIdentifier,
    if (attributes != null) 'attributes': attributes,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/SendEvent',
    exceptionFnMap: _exceptionFns,
  );
  return SendEventResponse.fromJson(response);
}