예제 #1
0
  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
  }
예제 #2
0
  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);
  }
예제 #3
0
  /** 1. 加载本地信息 2. 请求正规群信息 , 与本地进行对比 3. version groupId 请求 */
  public void onLocalLoginOk() {
    logger.i("group#loadFromDb");

    if (!EventBus.getDefault().isRegistered(inst)) {
      EventBus.getDefault().registerSticky(inst);
    }

    // 加载本地group
    List<GroupEntity> localGroupInfoList = dbInterface.loadAllGroup();
    for (GroupEntity groupInfo : localGroupInfoList) {
      groupMap.put(groupInfo.getPeerId(), groupInfo);
    }

    triggerEvent(new GroupEvent(GroupEvent.Event.GROUP_INFO_OK));
  }
예제 #4
0
  /** 收到群成员发生变更消息 服务端主动发出 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 没有就暂时不管了,只要聊过天都会显示在回话里面
    }
  }
예제 #5
0
  public void onRepGroupDetailInfo(IMGroup.IMGroupInfoListRsp groupInfoListRsp) {
    logger.i("group#onRepGroupDetailInfo");
    int groupSize = groupInfoListRsp.getGroupInfoListCount();
    int userId = groupInfoListRsp.getUserId();
    int loginId = imLoginManager.getLoginId();
    logger.i("group#onRepGroupDetailInfo cnt:%d", groupSize);
    if (groupSize <= 0 || userId != loginId) {
      logger.i("group#onRepGroupDetailInfo size empty or userid[%d]≠ loginId[%d]", userId, loginId);
      return;
    }
    ArrayList<GroupEntity> needDb = new ArrayList<>();
    for (IMBaseDefine.GroupInfo groupInfo : groupInfoListRsp.getGroupInfoListList()) {
      // 群组的详细信息
      // 保存在DB中
      // GroupManager 中的变量
      GroupEntity groupEntity = ProtoBuf2JavaBean.getGroupEntity(groupInfo);
      groupMap.put(groupEntity.getPeerId(), groupEntity);
      needDb.add(groupEntity);
    }

    dbInterface.batchInsertOrUpdateGroup(needDb);
    triggerEvent(new GroupEvent(GroupEvent.Event.GROUP_INFO_UPDATED));
  }