IntSeq RoomPool::GetRoomMember(const MucRoomIdPtr& roomid){ RoomMemberListPtr rmlptr; IntSeq ans; rmlptr = GetMemberList(roomid); if(rmlptr){ IceUtil::RWRecMutex::RLock lock(_rwmutex); ans = rmlptr->GetAllMembersSeq(); } MCE_DEBUG("RoomPool::GetRoomMember --> roomname = " << roomid->roomname << " ANS.SIZE = " << ans.size()); return ans; }
MucActiveUserSeq RoomPool::GetRoomActiveUserSeq(const MucRoomIdPtr& roomid){ MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> ROOMNAME = " << roomid->roomname); RoomMemberListPtr rmlptr; MucActiveUserSeq ans; MyUtil::IntSeq userids; rmlptr = GetMemberList(roomid); if(rmlptr){ IceUtil::RWRecMutex::RLock lock(_rwmutex); userids = rmlptr->GetAllMembersSeq(); } if(userids.empty()){ MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> userids is empty so return"); return ans; } JidSeqMap jseqmap; try{ MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> call OnlineCenterAdapter.getUsersJids userids.size = " << userids.size()); jseqmap = OnlineCenterAdapter::instance().getUsersJids(userids); } catch(Ice::Exception& e){ MCE_WARN("RoomPool::GetRoomActiveUserSeq-->OnlineCenter::getUserJids-->line:"<<__LINE__<<" err:"<<e); } catch(std::exception& e){ MCE_WARN("RoomPool::GetRoomActiveUserSeq--> call OnlineCenter.getUserJids ERR line:"<<__LINE__<<" err:"<<e.what()); } if(jseqmap.empty()){ return ans; } TalkUserMap uinfoPtr; try{ uinfoPtr = TalkCacheClient::instance().GetUserBySeqWithLoad(0, userids); }catch(Ice::Exception& e){ MCE_WARN("RoomPool::GetRoomActiveUserSeq-->TalkCacheClient::GetUserBySeqWithLoad-->error:" << e); } MyUtil::IntSeq::iterator uidit = userids.begin(); for(; uidit != userids.end(); ++uidit){ int userid = (*uidit); JidSeqMap::const_iterator jit = jseqmap.find(userid); if(jit == jseqmap.end()){ continue; } Permisions permision = PMember; try{ MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> CALL MucUserRoomAdapter.GetMemberPermision(" << userid << ", " << roomid->roomname << ")"); MucMemberPtr m = MucUserRoomAdapter::instance().GetMemberPermision(userid, roomid); if(m){ permision = m->permision; } else{ MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> CALL MucUserRoomAdapter.GetMemberPermision's return is NULL, it means the user is not in the room so continue!"); continue; } } catch(Ice::Exception& e){ MCE_WARN("RoomPool::GetRoomActiveUserSeq-->MucUserRoom::GetMemberPermision-->line:"<<__LINE__<<" err:"<<e); } catch(std::exception& e){ MCE_WARN("RoomPool::GetRoomActiveUserSeq--> call MucUserRoom.GetMemberPermision ERR line:"<<__LINE__<<" err:"<<e.what()); } string nickname = ""; TalkUserMap::iterator infoit = uinfoPtr.find(userid); if(infoit == uinfoPtr.end()){ //取不到用户的名称,默认用id try{ nickname = boost::lexical_cast<string>(userid); } catch (exception& e){ MCE_WARN("RoomPool::GetRoomActiveUserSeq-->boost::lexical_cast to string exception val = " << userid); } } else{ TalkUserPtr u = infoit->second; nickname = u->name; } for (size_t index = 0; index < jit->second.size(); ++index) { char endpoint = jit->second.at(index)->endpoint[0]; if(endpoint != 'T' && endpoint != 'W'){ continue; } MucRoomIdPtr roomid = new MucRoomId(); roomid->roomname = rmlptr->_roomname; roomid->domain = MUCDOMAIN; MucUserIdentityPtr identity = new MucUserIdentity(); identity->roomid = roomid; identity->nickname = makeMucNickname(jit->second.at(index), nickname); identity->userid = userid; MucActiveUserPtr activeuserptr = new MucActiveUser(); activeuserptr->jid = jit->second.at(index); activeuserptr->identity = identity; activeuserptr->permision = permision; ans.push_back(activeuserptr); } } MCE_DEBUG("RoomPool::GetRoomActiveUserSeq --> roomname = " << roomid->roomname << " ans.size = " << ans.size()); return ans; }