sendAction method

  1. @override
void sendAction(
  1. String contactPubsubToken,
  2. ChatwootActionType actionType
)
override

Implementation

@override
void sendAction(String contactPubsubToken, ChatwootActionType actionType) {
  final ChatwootAction action;
  final identifier = jsonEncode(
      {"channel": "RoomChannel", "pubsub_token": contactPubsubToken});
  switch (actionType) {
    case ChatwootActionType.subscribe:
      action = ChatwootAction(identifier: identifier, command: "subscribe");
      break;
    default:
      action = ChatwootAction(
          identifier: identifier,
          data: ChatwootActionData(action: actionType),
          command: "message");
      break;
  }
  connection?.sink.add(jsonEncode(action.toJson()));
}