public List<UserEntity> getGroupMembers(int groupId) { logger.d("group#getGroupMembers groupId:%s", groupId); GroupEntity group = findGroup(groupId); if (group == null) { logger.e("group#no such group id:%s", groupId); return null; } Set<Integer> userList = group.getlistGroupMemberIds(); ArrayList<UserEntity> memberList = new ArrayList<UserEntity>(); for (Integer id : userList) { UserEntity contact = IMContactManager.instance().findContact(id); if (contact == null) { logger.e("group#no such contact id:%s", id); continue; } memberList.add(contact); } return memberList; }
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 }
/** 请求群组的详细信息 */ public void reqGetGroupDetailInfo(List<IMBaseDefine.GroupVersionInfo> versionInfoList) { logger.i("group#reqGetGroupDetailInfo"); if (versionInfoList == null || versionInfoList.size() <= 0) { logger.e("group#reqGetGroupDetailInfo# please check your params,cause by empty/null"); return; } int loginId = imLoginManager.getLoginId(); IMGroup.IMGroupInfoListReq groupInfoListReq = IMGroup.IMGroupInfoListReq.newBuilder() .setUserId(loginId) .addAllGroupVersionList(versionInfoList) .build(); int sid = IMBaseDefine.ServiceID.SID_GROUP_VALUE; int cid = IMBaseDefine.GroupCmdID.CID_GROUP_INFO_REQUEST_VALUE; imSocketManager.sendRequest(groupInfoListReq, sid, cid); }