sendMessage method

Future<void> sendMessage({
  1. required Participant to,
  2. required String type,
  3. required Map<String, dynamic> message,
  4. Uint8List? attachment,
  5. bool ignoreOffline = false,
})

Implementation

Future<void> sendMessage({
  required Participant to,
  required String type,
  required Map<String, dynamic> message,
  Uint8List? attachment,
  bool ignoreOffline = false,
}) async {
  final resolvedTo = _resolveMessageRecipient(to);
  if (resolvedTo == null) {
    if (ignoreOffline) {
      return;
    }
    throw RoomServerException("the participant was not found");
  }

  await room.invoke(
    toolkit: "messaging",
    tool: "send",
    input: ToolContentInput(
      JsonContent(
        json: _messageInput(toParticipantId: resolvedTo.id, type: type, message: message, attachment: attachment),
      ),
    ),
  );
}