Пример #1
0
int RoomPool::GetUserCount(const MucRoomIdPtr& roomid){
  IceUtil::RWRecMutex::RLock lock(_rwmutex);
  RoomInfoPtr riptr = GetRoom(roomid);
  if(riptr){
    return riptr->GetUserCount();
  }
}
Пример #2
0
void RoomPool::AwayRoom(const JidPtr& opuser, const MucRoomIdPtr& roomid){
  //如果一个用户的副本进入了在线中心,那么这个用户退出在线中心的行为是下线。
  //第三方副本可以awayroom
  RoomInfoPtr riptr;
  MucActiveUserPtr opaptr;
  //MucActiveUserSeq presenceUsers;
  JidSeq presenceUsers;
  bool awayok = false;
  bool kickroomok = false;
	int mucstatus = 0;
  {
    IceUtil::RWRecMutex::WLock lock(_rwmutex);
    riptr = GetRoom(roomid);
		if(!riptr){
			return;
		}
    opaptr = riptr->GetActiveUser(opuser);
    awayok = riptr->AwayRoom(opuser);
    if(awayok && !riptr->GetUserCount()){
      MCE_DEBUG("RoomPool::AwayRoom --> user away ok and room is empty so kick it");
      kickroomok = KickRoom(roomid);
    }
  }

  if(awayok){
    if(!kickroomok){
      IceUtil::RWRecMutex::RLock lock(_rwmutex);
      presenceUsers = riptr->GetAllActiveJids();
			mucstatus = riptr->GetUserMucStatus(opuser->userId);
    }
		if(opaptr){
    	presenceUsers.push_back(opaptr->jid);
		}
  }

  if(awayok && opaptr && !presenceUsers.empty()){
    MucGateAdapter::instance().NotifyUserAwayRoom(opaptr, presenceUsers, mucstatus);
  }
  MCE_DEBUG("RoomPool::AwayRoom --> jid = " << jidToString(opuser) << " roomname = " << roomid->roomname << " awayok = " << awayok << " mucstatus = " << mucstatus);
}