Callback listeners

Observe Group Events Individually#

To observe group related events you can implement the following listeners

Group Profile Fetched#

When the request for fetching a group profile is completed successfully this callback will be triggered.

Mirrorfly.onGroupProfileFetched.listen((event){
//Group profile jid data fetched.
});

Group notification message received#

When events like new member added or member removed a notification message will be generated locally and inserted in the local database. After insertion this callback will be triggered.

Mirrorfly.onGroupNotificationMessage.listen((event){
//Group Notification message received
ChatMessageModel chatMessageModel = sendMessageModelFromJson(event.toString());
});

New group created#

When a new group was created like when someone added you to a group this callback will be triggered.

Mirrorfly.onNewGroupCreated.listen((event){
//New group created jid
});

Group profile updated#

When a group profile is updated this callback will be triggered.

Mirrorfly.onGroupProfileUpdated.listen((event){
//Group profile updated jid
});

New member added to group#

When a new member is added to the group this callback will be triggered.

Mirrorfly.onNewMemberAddedToGroup.listen((event){
var data = json.decode(event.toString());
var groupJid = data["groupJid"];
var newMemberJid = data["newMemberJid"];
var addedByMemberJid = data["addedByMemberJid"];
//New member added to a group successfully
});

Member removed from group#

When a member is removed from the group this callback will be triggered.

Mirrorfly.onMemberRemovedFromGroup.listen((event){
var data = json.decode(event.toString());
var groupJid = data["groupJid"];
var removedMemberJid = data["removedMemberJid"];
var removedByMemberJid = data["removedByMemberJid"];
// A group member was removed
});

Fetching group members#

When a group is created, members of that group will be fetched once sucessfully fetched this callback will be triggered.

Mirrorfly.onFetchingGroupMembersCompleted.listen((event){
// Members fetched successfully of a group jid
});

Group member became an admin#

When a group member became an admin this callback will be triggered.

Mirrorfly.onMemberMadeAsAdmin.listen((event){
var data = json.decode(event.toString());
var groupJid = data["groupJid"];
var newAdminMemberJid = data["newAdminMemberJid"];
var madeByMemberJid = data["madeByMemberJid"];
// A group member was made an admin
});

Admin access revoked#

When a group member's admin access is revoked this callback will be triggered.

Mirrorfly.onMemberRemovedAsAdmin.listen((event){
var data = json.decode(event.toString());
var groupJid = data["groupJid"];
var removedAdminMemberJid = data["removedAdminMemberJid"];
var removedByMemberJid = data["removedByMemberJid"];
// A group admin access was revoked
});

Member left from the group#

When a member left the group this callback will be triggered.

Mirrorfly.onLeftFromGroup.listen((event){
// A group member left from the group
var data = json.decode(event.toString());
var groupJid = data["groupJid"];
var leftUserJid = data["leftUserJid"];
});

Group deleted locally#

When the current user delete a group locally this callback will be triggered.

Mirrorfly.onGroupDeletedLocally.listen((event){
// A group was deleted locally
});

Observing the Group events Collectively#

Assign the listener to the appropriate class to receive event updates. Extend the class and implement the necessary event listeners collectively for streamlined integration you can register your own listener by using the below method.

tip

There can be only one message listener at a time, if you set multiple times using the below method it will replace the old listener always.

Mirrorfly.setGroupEventListener(YourClass());
class YourClass extends GroupEventListeners{
@override
void onFetchingGroupMembersCompleted(String groupJid) {
// TODO: implement onFetchingGroupMembersCompleted
}
@override
void onGroupDeletedLocally(String groupJid) {
// TODO: implement onGroupDeletedLocally
}
@override
void onGroupNotificationMessage(ChatMessageModel groupNotificationMessage) {
// TODO: implement onGroupNotificationMessage
}
@override
void onGroupProfileFetched(String groupJid) {
// TODO: implement onGroupProfileFetched
}
@override
void onGroupProfileUpdated(String groupJid) {
// TODO: implement onGroupProfileUpdated
}
@override
void onLeftFromGroup(String groupJid, String leftUserJid) {
// TODO: implement onLeftFromGroup
}
@override
void onMemberMadeAsAdmin(String groupJid, String newAdminMemberJid, String madeByMemberJid) {
// TODO: implement onMemberMadeAsAdmin
}
@override
void onMemberRemovedAsAdmin(String groupJid, String removedAdminMemberJid, String removedByMemberJid) {
// TODO: implement onMemberRemovedAsAdmin
}
@override
void onMemberRemovedFromGroup(String groupJid, String removedMemberJid, String removedByMemberJid) {
// TODO: implement onMemberRemovedFromGroup
}
@override
void onNewGroupCreated(String groupJid) {
// TODO: implement onNewGroupCreated
}
@override
void onNewMemberAddedToGroup(String groupJid, String newMemberJid, String addedByMemberJid) {
// TODO: implement onNewMemberAddedToGroup
}
}