public void onReqCreateTempGroup(IMGroup.IMGroupCreateRsp groupCreateRsp) { logger.d("group#onReqCreateTempGroup"); int resultCode = groupCreateRsp.getResultCode(); if (0 != resultCode) { logger.e("group#createGroup failed"); triggerEvent(new GroupEvent(GroupEvent.Event.CREATE_GROUP_FAIL)); return; } GroupEntity groupEntity = ProtoBuf2JavaBean.getGroupEntity(groupCreateRsp); // 更新DB 更新map groupMap.put(groupEntity.getPeerId(), groupEntity); IMSessionManager.instance().updateSession(groupEntity); dbInterface.insertOrUpdateGroup(groupEntity); triggerEvent(new GroupEvent(GroupEvent.Event.CREATE_GROUP_OK, groupEntity)); // 接收到之后修改UI }
/** 收到群成员发生变更消息 服务端主动发出 DB */ public void receiveGroupChangeMemberNotify(IMGroup.IMGroupChangeMemberNotify notify) { int groupId = notify.getGroupId(); int changeType = ProtoBuf2JavaBean.getGroupChangeType(notify.getChangeType()); List<Integer> changeList = notify.getChgUserIdListList(); List<Integer> curMemberList = notify.getCurUserIdListList(); if (groupMap.containsKey(groupId)) { GroupEntity entity = groupMap.get(groupId); entity.setlistGroupMemberIds(curMemberList); dbInterface.insertOrUpdateGroup(entity); groupMap.put(groupId, entity); GroupEvent groupEvent = new GroupEvent(GroupEvent.Event.CHANGE_GROUP_MEMBER_SUCCESS); groupEvent.setChangeList(changeList); groupEvent.setChangeType(changeType); groupEvent.setGroupEntity(entity); triggerEvent(groupEvent); } else { // todo 没有就暂时不管了,只要聊过天都会显示在回话里面 } }
public void onReqChangeGroupMember(IMGroup.IMGroupChangeMemberRsp groupChangeMemberRsp) { int resultCode = groupChangeMemberRsp.getResultCode(); if (0 != resultCode) { triggerEvent(new GroupEvent(GroupEvent.Event.CHANGE_GROUP_MEMBER_FAIL)); return; } int groupId = groupChangeMemberRsp.getGroupId(); List<Integer> changeUserIdList = groupChangeMemberRsp.getChgUserIdListList(); IMBaseDefine.GroupModifyType groupModifyType = groupChangeMemberRsp.getChangeType(); GroupEntity groupEntityRet = groupMap.get(groupId); groupEntityRet.setlistGroupMemberIds(groupChangeMemberRsp.getCurUserIdListList()); groupMap.put(groupId, groupEntityRet); dbInterface.insertOrUpdateGroup(groupEntityRet); GroupEvent groupEvent = new GroupEvent(GroupEvent.Event.CHANGE_GROUP_MEMBER_SUCCESS); groupEvent.setChangeList(changeUserIdList); groupEvent.setChangeType(ProtoBuf2JavaBean.getGroupChangeType(groupModifyType)); groupEvent.setGroupEntity(groupEntityRet); triggerEvent(groupEvent); }