sendLiveSpaceData function

Future sendLiveSpaceData({
  1. required String messageType,
  2. required LiveSpaceData updatedLiveSpaceData,
  3. required String content,
  4. required List<String> affectedAddresses,
  5. required String spaceId,
})

Implementation

Future sendLiveSpaceData({
  required String messageType,
  required LiveSpaceData updatedLiveSpaceData,
  required String content,
  required List<String> affectedAddresses,
  required String spaceId,
}) async {
  if (messageType != MessageType.META &&
      messageType != MessageType.USER_ACTIVITY) {
    throw Exception(
        "Live space data supports only META, USER_ACTIVITY message types");
  }

  final message = messageType == MessageType.META
      ? MetaMessage(
          info: Info(
            affected: affectedAddresses,
            arbitrary: updatedLiveSpaceData.toJson(),
          ),
          content: content,
        )
      : UserActivityMessage(
          info: Info(
            affected: affectedAddresses,
            arbitrary: updatedLiveSpaceData.toJson(),
          ),
          content: content,
        );

  final options = ChatSendOptions(
    messageType: messageType,
    message: message,
    recipient: spaceId,
  );

  return send(options);
}