Example #1
0
RoomMemberListPtr RoomPool::SelectRoomMembers(const MucRoomIdPtr& roomid){
  int irid = GetIdFromMucRoomId(roomid);
	if(!irid){
		return NULL;
	}
  Statement sql;
  string tablename = GetDbTableName(irid);

  RoomMemberListPtr rmlptr = new RoomMemberList(roomid->roomname, irid);
  //sql<< "select member_id from " << tablename << " where minigroup_id = " << irid;
  sql << "select user_id, member_type from " << tablename << " where session_id = " << irid;
  MCE_DEBUG("RoomPool::SelectRoomMembers-->tablename," << tablename);
  mysqlpp::StoreQueryResult res = QueryRunner(DB_INSTANCE, CDbRServer, tablename).store(sql);
  if (res && res.num_rows() > 0) {
    for (size_t i = 0; i < res.num_rows(); ++i) {
      mysqlpp::Row row = res.at(i);
      // int userid = (int)row["member_id"];
      //MCE_DEBUG("RoomPool::SelectRoomMembers-->user_id," << (int)row["user_id"] << ",member_type," << (int)row["member_type"]);
      if (1 == (int)row["member_type"]) {
        int userid = (int)row["user_id"];
        rmlptr->AddMember(userid);

      }
    }
  }
	return rmlptr;
}
Example #2
0
void RoomPool::AddRoomMember(int userid, const MucRoomIdPtr& roomid){
  RoomMemberListPtr rmlptr;
  bool addok = false;
  rmlptr = GetMemberList(roomid);
  if(rmlptr){
    IceUtil::RWRecMutex::WLock lock(_rwmutex);
    addok = rmlptr->AddMember(userid);
  }
  MCE_DEBUG("RoomPool::AddRoomMember --> userid = " << userid << " roomname = " << roomid->roomname << " addok = " << addok);
}
Example #3
0
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;
}
Example #4
0
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;
}