ShowAlert typedef
Sends a message to the server.
The parameters map should contain the following keys:
- 'member': The member's name (optional, default: '').
- 'islevel': The level of the member (optional, default: '1').
- 'showAlert': A function to show an alert (optional).
- 'coHostResponsibility': A list of co-host responsibilities (optional, default: []).
- 'coHost': The co-host's name (optional, default: '').
- 'chatSetting': The chat setting (optional, default: '').
- 'message': The message to send (optional).
- 'roomName': The name of the room (optional, default: '').
- 'messagesLength': The length of the messages (optional, default: 0).
- 'receivers': A list of message receivers (optional, default: []).
- 'group': A flag indicating if it's a group message (optional, default: false).
- 'sender': The sender's name (optional).
- 'socket': The socket to communicate with the server.
The function checks the message count limit based on the room type and shows an alert if the limit is exceeded. It validates the message, sender, and receivers and shows an alert if they are not valid. It creates a message object with the sender, receivers, message, timestamp, and group flag. It checks the co-host responsibility for chat and allows sending the message if the conditions are met. If the user is not allowed to send a message in the event room, it shows an alert. Finally, it sends the message to the server using the provided socket.
Implementation
typedef ShowAlert = void Function({
required String message,
required String type,
required int duration,
});