initializetestmessageStream static method
dynamic
initializetestmessageStream()
Implementation
static initializetestmessageStream() {
nativeStream = eventStreamChannel.receiveBroadcastStream(1).map((e) {
switch (e["methodName"]) {
///Mark -- Message Listeners
case "onTextMessageReceived":
BaseMessage receivedMessage = BaseMessage.fromMap(e);
_messageListeners.values.forEach((element) {
element.onTextMessageReceived(receivedMessage as TextMessage);
});
break;
case "onMediaMessageReceived":
BaseMessage receivedMessage = BaseMessage.fromMap(e);
_messageListeners.values.forEach((element) {
element.onMediaMessageReceived(receivedMessage as MediaMessage);
});
break;
case "onTypingStarted":
TypingIndicator typingIndicator = TypingIndicator.fromMap(e);
_messageListeners.values.forEach((element) {
element.onTypingStarted(typingIndicator);
});
break;
case "onTypingEnded":
TypingIndicator typingIndicator = TypingIndicator.fromMap(e);
_messageListeners.values.forEach((element) {
element.onTypingEnded(typingIndicator);
});
break;
case "onMessagesDelivered":
MessageReceipt messageReceipt = MessageReceipt.fromMap(e);
_messageListeners.values.forEach((element) {
element.onMessagesDelivered(messageReceipt);
});
break;
case "onMessagesRead":
MessageReceipt messageReceipt = MessageReceipt.fromMap(e);
_messageListeners.values.forEach((element) {
element.onMessagesRead(messageReceipt);
});
break;
case "onMessagesDeliveredToAll":
MessageReceipt messageReceipt = MessageReceipt.fromMap(e);
_messageListeners.values.forEach((element) {
element.onMessagesDeliveredToAll(messageReceipt);
});
break;
case "onMessagesReadByAll":
MessageReceipt messageReceipt = MessageReceipt.fromMap(e);
_messageListeners.values.forEach((element) {
element.onMessagesReadByAll(messageReceipt);
});
break;
case "onMessageEdited":
BaseMessage receivedMessage = BaseMessage.fromMap(e);
_messageListeners.values.forEach((element) {
element.onMessageEdited(receivedMessage);
});
break;
case "onMessageDeleted":
BaseMessage receivedMessage = BaseMessage.fromMap(e);
_messageListeners.values.forEach((element) {
element.onMessageDeleted(receivedMessage);
});
break;
case "onTransientMessageReceived":
TransientMessage receivedMessage = TransientMessage.fromMap(e);
_messageListeners.values.forEach((element) {
element.onTransientMessageReceived(receivedMessage);
});
break;
case "onCustomMessageReceived":
CustomMessage receivedMessage = CustomMessage.fromMap(e);
_messageListeners.values.forEach((element) {
element.onCustomMessageReceived(receivedMessage);
});
break;
case "onInteractiveMessageReceived":
InteractiveMessage receivedMessage = InteractiveMessage.fromMap(e);
_messageListeners.values.forEach((element) {
element.onInteractiveMessageReceived(receivedMessage);
});
break;
case "onInteractionGoalCompleted":
InteractionReceipt receipt = InteractionReceipt.fromMap(e);
_messageListeners.values.forEach((element) {
element.onInteractionGoalCompleted(receipt);
});
break;
///Mark -- User Listeners
case "onUserOnline":
User user = User.fromMap(e);
_userListeners.values.forEach((element) {
element.onUserOnline(user);
});
break;
case "onUserOffline":
User user = User.fromMap(e);
_userListeners.values.forEach((element) {
element.onUserOffline(user);
});
break;
///Mark -- Group Listeners
case "onGroupMemberJoined":
action_import.Action action =
action_import.Action.fromMap(e["action"]);
User joinedUser = User.fromMap(e["joinedUser"]);
Group joinedGroup = Group.fromMap(e["joinedGroup"]);
_groupListeners.values.forEach((element) {
element.onGroupMemberJoined(action, joinedUser, joinedGroup);
});
break;
case "onGroupMemberLeft":
action_import.Action action =
action_import.Action.fromMap(e["action"]);
User leftUser = User.fromMap(e["leftUser"]);
Group leftGroup = Group.fromMap(e["leftGroup"]);
_groupListeners.values.forEach((element) {
element.onGroupMemberLeft(action, leftUser, leftGroup);
});
break;
case "onGroupMemberKicked":
action_import.Action action =
action_import.Action.fromMap(e["action"]);
User kickedUser = User.fromMap(e["kickedUser"]);
User kickedBy = User.fromMap(e["kickedBy"]);
Group kickedFrom = Group.fromMap(e["kickedFrom"]);
_groupListeners.values.forEach((element) {
element.onGroupMemberKicked(
action, kickedUser, kickedBy, kickedFrom);
});
break;
case "onGroupMemberBanned":
action_import.Action action =
action_import.Action.fromMap(e["action"]);
User bannedUser = User.fromMap(e["bannedUser"]);
User bannedBy = User.fromMap(e["bannedBy"]);
Group bannedFrom = Group.fromMap(e["bannedFrom"]);
_groupListeners.values.forEach((element) {
element.onGroupMemberBanned(
action, bannedUser, bannedBy, bannedFrom);
});
break;
case "onGroupMemberUnbanned":
action_import.Action action =
action_import.Action.fromMap(e["action"]);
User unbannedUser = User.fromMap(e["unbannedUser"]);
User unbannedBy = User.fromMap(e["unbannedBy"]);
Group unbannedFrom = Group.fromMap(e["unbannedFrom"]);
_groupListeners.values.forEach((element) {
element.onGroupMemberUnbanned(
action, unbannedUser, unbannedBy, unbannedFrom);
});
break;
case "onGroupMemberScopeChanged":
action_import.Action action =
action_import.Action.fromMap(e["action"]);
User updatedBy = User.fromMap(e["updatedBy"]);
User updatedUser = User.fromMap(e["updatedUser"]);
String scopeChangedTo = e["scopeChangedTo"];
String scopeChangedFrom = e["scopeChangedFrom"];
Group group = Group.fromMap(e["group"]);
_groupListeners.values.forEach((element) {
element.onGroupMemberScopeChanged(action, updatedBy, updatedUser,
scopeChangedTo, scopeChangedFrom, group);
});
break;
case "onMemberAddedToGroup":
action_import.Action action =
action_import.Action.fromMap(e["action"]);
User addedby = User.fromMap(e["addedby"]);
User userAdded = User.fromMap(e["userAdded"]);
Group addedTo = Group.fromMap(e["addedTo"]);
_groupListeners.values.forEach((element) {
element.onMemberAddedToGroup(action, addedby, userAdded, addedTo);
});
break;
///Mark -- Login Listeners
case "loginSuccess":
User user = User.fromMap(e);
_loginListeners.values.forEach((element) {
element.loginSuccess(user);
});
break;
case "loginFailure":
CometChatException excep = CometChatException.fromMap(e);
_loginListeners.values.forEach((element) {
element.loginFailure(excep);
});
break;
case "logoutSuccess":
_loginListeners.values.forEach((element) {
element.logoutSuccess();
});
break;
case "logoutFailure":
CometChatException excep = CometChatException.fromMap(e);
_loginListeners.values.forEach((element) {
element.loginFailure(excep);
});
break;
///Mark -- Connection Listeners
case "onConnected":
_connectionListeners.values.forEach((element) {
element.onConnected();
});
break;
case "onConnecting":
_connectionListeners.values.forEach((element) {
element.onConnecting();
});
break;
case "onDisconnected":
_connectionListeners.values.forEach((element) {
element.onDisconnected();
});
break;
case "onFeatureThrottled":
_connectionListeners.values.forEach((element) {
element.onFeatureThrottled();
});
break;
case "onConnectionError":
_connectionListeners.values.forEach((element) {
CometChatException error = CometChatException.fromMap(e["error"]);
element.onConnectionError(error);
});
break;
///Call-SDK-changes
case "onIncomingCallReceived":
_callListener.values.forEach((element) {
Call call = Call.fromMap(e["call"]);
element.onIncomingCallReceived(call);
});
break;
case "onOutgoingCallAccepted":
_callListener.values.forEach((element) {
Call call = Call.fromMap(e["call"]);
element.onOutgoingCallAccepted(call);
});
break;
case "onOutgoingCallRejected":
_callListener.values.forEach((element) {
Call call = Call.fromMap(e["call"]);
element.onOutgoingCallRejected(call);
});
break;
case "onIncomingCallCancelled":
_callListener.values.forEach((element) {
Call call = Call.fromMap(e["call"]);
element.onIncomingCallCancelled(call);
});
break;
case "onCallEndedMessageReceived":
_callListener.values.forEach((element) {
Call call = Call.fromMap(e["call"]);
element.onCallEndedMessageReceived(call);
});
break;
///Reactions
case "onMessageReactionAdded":
_messageListeners.values.forEach((element) {
ReactionEvent reactionEvent =
ReactionEvent.fromMap(e["reactionEvent"]);
element.onMessageReactionAdded(reactionEvent);
});
break;
case "onMessageReactionRemoved":
_messageListeners.values.forEach((element) {
ReactionEvent reactionEvent =
ReactionEvent.fromMap(e["reactionEvent"]);
element.onMessageReactionRemoved(reactionEvent);
});
break;
}
});
}