void onMembersLeft(final List<String> members, final String removedBy) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (handler != null) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = client.getConversation(this.conversationId); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { handler.processEvent(Conversation.STATUS_ON_MEMBERS_LEFT, removedBy, members, conversation); } }); } }
void onConversationReadAtEvent(final long readAt) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (handler != null) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = client.getConversation(this.conversationId); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { handler.processEvent(Conversation.STATUS_ON_MESSAGE_READ, readAt, null, conversation); } }); } }
void onMembersJoined(final List<String> members, final String invitedBy) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (handler != null) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = client.getConversation(this.conversationId); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { handler.processEvent(Conversation.STATUS_ON_MEMBERS_JOINED, invitedBy, members, conversation); } }); } }
void onConversationDeliveredAtEvent(final long deliveredAt) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (handler != null) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = client.getConversation(this.conversationId); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { handler.processEvent(Conversation.STATUS_ON_MESSAGE_DELIVERED, deliveredAt, null, conversation); } }); } }
void onInvitedToConversation(final String invitedBy, Messages.ConvCommand convCommand) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (handler != null) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = parseConversation(client, convCommand); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { handler.processEvent(Conversation.STATUS_ON_JOINED, invitedBy, null, conversation); } }); } }
void onSelfShutupedNotify(final boolean isMuted, final String operator, Messages.ConvCommand convCommand) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (handler != null) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = parseConversation(client, convCommand); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { if (isMuted) { handler.processEvent(Conversation.STATUS_ON_MUTED, operator, null, conversation); } else { handler.processEvent(Conversation.STATUS_ON_UNMUTED, operator, null, conversation); } } }); } }
void onMessageUpdateEvent(final AVIMMessage message, final boolean isRecall) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (handler != null) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = client.getConversation(this.conversationId); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { if (isRecall) { handler.processEvent(Conversation.STATUS_ON_MESSAGE_RECALLED, message, null, conversation); } else { handler.processEvent(Conversation.STATUS_ON_MESSAGE_UPDATED, message, null, conversation); } } }); } }
void onSelfBlockedNotify(final boolean isBlocked, final String operator, Messages.ConvCommand convCommand) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (null == handler) { return; } AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = parseConversation(client, convCommand); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { if (isBlocked) { handler.processEvent(Conversation.STATUS_ON_BLOCKED, operator, null, conversation); } else { handler.processEvent(Conversation.STATUS_ON_UNBLOCKED, operator, null, conversation); } } }); }
void onMemberShutupedNotify(final boolean isMuted, final String operator, Messages.ConvCommand convCommand) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); List<String> members = convCommand.getMList(); if (handler != null && null != members) { final List<String> copyMembers = new ArrayList<>(members); copyMembers.remove(session.getSelfPeerId()); if (copyMembers.size() < 1) { // ignore self member_shutuped notify, bcz server sends both shutuped and member_shutuped notification. LogUtil.log.d("Notification --- ignore shutuped/unshutuped notify bcz duplicated."); } else { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = parseConversation(client, convCommand); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { if (isMuted) { handler.processEvent(Conversation.STATUS_ON_MEMBER_MUTED, operator, copyMembers, conversation); } else { handler.processEvent(Conversation.STATUS_ON_MEMBER_UNMUTED, operator, copyMembers, conversation); } } }); } } }
void onInfoChangedNotify(Messages.ConvCommand convCommand) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (null != handler) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = parseConversation(client, convCommand); final String operator = convCommand.getInitBy(); Messages.JsonObjectMessage attrMsg = convCommand.getAttr(); JSONObject operand = null; if (null == attrMsg || null == attrMsg.getData() || attrMsg.getData().trim().length() < 1) { // attached data is empty conversation.setMustFetch(); } else { // diff data is pushed, but deleted attr is ignored. operand = JSON.parseObject(attrMsg.getData()); AVIMConversation.mergeConversationFromJsonObject(conversation, operand); } // Notice: SDK doesn't refresh conversation data automatically. handler.processEvent(Conversation.STATUS_ON_INFO_CHANGED, operator, operand, conversation); } } void onKickedFromConversation(final String invitedBy) {
void onMemberBlockedNotify(final boolean isBlocked, final String operator, Messages.ConvCommand convCommand) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); final List<String> members = convCommand.getMList(); if (handler != null && null != members) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = parseConversation(client, convCommand); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { if (isBlocked) { handler.processEvent(Conversation.STATUS_ON_MEMBER_BLOCKED, operator, members, conversation); } else { handler.processEvent(Conversation.STATUS_ON_MEMBER_UNBLOCKED, operator, members, conversation); } } }); } }
void onKickedFromConversation(final String invitedBy) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = client.getConversation(this.conversationId); if (handler != null) { refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { handler.processEvent(Conversation.STATUS_ON_KICKED_FROM_CONVERSATION, invitedBy, null, conversation); } }); } session.removeConversation(conversationId); AVIMMessageManagerHelper.removeConversationCache(conversation); }
/** * process the unread messages event */ void onUnreadMessagesEvent(AVIMMessage message, int unreadCount, boolean mentioned) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (null == handler) { LogUtil.log.d("conversation event handler is none."); } else { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = client.getConversation(this.conversationId); if (conversation.getUnreadMessagesCount() == unreadCount) { LogUtil.log.d("unread count isn't changed, ignore command..."); } else { final Pair<Integer, Boolean> unreadInfo = new Pair<>(unreadCount, mentioned); if (null != message) { message.setMessageIOType(AVIMMessage.AVIMMessageIOType.AVIMMessageIOTypeIn); message.setMessageStatus(AVIMMessage.AVIMMessageStatus.AVIMMessageStatusSent); message = AVIMMessageManagerHelper.parseTypedMessage(message); } final AVIMMessage msgCopy = message; refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { handler.processEvent(Conversation.STATUS_ON_UNREAD_EVENT, msgCopy, unreadInfo, conversation); } }); } } }
private void onMemberChanged(final String operator, Messages.ConvMemberInfo member) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (handler != null) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = client.getConversation(this.conversationId); final String objectId = member.getInfoId(); final String roleStr = member.getRole(); final String peerId = member.getPid(); final AVIMConversationMemberInfo memberInfo = new AVIMConversationMemberInfo(objectId, conversationId, peerId, ConversationMemberRole.fromString(roleStr)); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { handler.processEvent(Conversation.STATUS_ON_MEMBER_INFO_CHANGED, operator, memberInfo, conversation); } }); } }