Example #1
0
void RoomPool::SetPermision(int opuser, Permisions permision, int targetuser, const MucRoomIdPtr& roomid){
  MCE_DEBUG("RoomPool::SetPermision --> opuser = "******" permision = " << permision << " targetuser = "******" roomname = " << roomid->roomname);
  MucActiveUserPtr opaptr;
  MucActiveUserSeq targetseq;
  JidSeq presenceUsers;
  RoomInfoPtr riptr;
  {
    IceUtil::RWRecMutex::WLock lock(_rwmutex);
    riptr = GetRoom(roomid);
    if(riptr){
      targetseq = riptr->GetActiveUserSeq(targetuser);
      riptr->SetPermision(targetuser, permision);
    }
  }
  if(riptr){
    IceUtil::RWRecMutex::RLock lock(_rwmutex);
    opaptr = riptr->GetActiveUser(opuser);
    if(opaptr){
      presenceUsers = riptr->GetAllActiveJids();
      if(permision == POutcast || permision == PNone){
				//如果是踢人的话,要把自己加上,notify self
        for(MucActiveUserSeq::iterator it = targetseq.begin(); it != targetseq.end(); ++it){
          presenceUsers.push_back((*it)->jid);
        }
      }
    }
  }
  if(riptr && opaptr && !presenceUsers.empty()){
    MucGateAdapter::instance().NotifySetPermision(opaptr, presenceUsers, targetseq, permision);
  }
}
Example #2
0
bool RoomPool::SetPermisionForIM(int opuser, Permisions permision, int targetuser, const MucRoomIdPtr& roomid){
  bool setok = false;
  MucActiveUserPtr opaptr;
  MucActiveUserSeq targetseq;
  JidSeq presenceUsers;
  RoomInfoPtr riptr;
  {
    IceUtil::RWRecMutex::WLock lock(_rwmutex);
    riptr = GetRoom(roomid);
    if(riptr){
      targetseq = riptr->GetActiveUserSeq(targetuser);
      setok = riptr->SetPermisionForIM(opuser, permision, targetuser);
    }
    else{
      return false;
    }
  }
  if(setok){
    IceUtil::RWRecMutex::RLock lock(_rwmutex);
    opaptr = riptr->GetActiveUser(opuser);
    if(opaptr){
      presenceUsers = riptr->GetAllActiveJids();
      if(permision == POutcast || permision == PNone){
        for(MucActiveUserSeq::iterator it = targetseq.begin(); it != targetseq.end(); ++it){
          presenceUsers.push_back((*it)->jid);
        }
      }
    }
  }
  if(setok && opaptr && !presenceUsers.empty()){
    MucGateAdapter::instance().NotifySetPermision(opaptr, presenceUsers, targetseq, permision);
  }
  return setok;
}
Example #3
0
void RoomPool::ChatSetingChange(int userid, const MucRoomIdPtr& roomid, int set){
	RoomInfoPtr riptr;
	MucActiveUserSeq seq;
	MCE_DEBUG("RoomPool::ChatSetingChange --> userid = " << userid << " roomid = " << mucRoomIdToString(roomid) << " set = " << set);
	{
		IceUtil::RWRecMutex::RLock lock(_rwmutex);
		riptr = GetRoom(roomid);
		if(riptr){
			seq = riptr->GetActiveUserSeq(userid);
		}
	}
	if(seq.empty()){
		MCE_DEBUG("RoomPool::ChatSetingChange --> userid = " << userid << " roomid = " << mucRoomIdToString(roomid) << " set = " << set << " no MucActiveUserSeq");
		return;
	}
	JidSeq webjids;
	for(MucActiveUserSeq::iterator ait = seq.begin(); ait != seq.end(); ++ait){
		if('W' == (*ait)->jid->endpoint[0]){
			webjids.push_back((*ait)->jid);
		}
	}
	if(webjids.empty()){
		MCE_DEBUG("RoomPool::ChatSetingChange --> userid = " << userid << " roomid = " << mucRoomIdToString(roomid) << " set = " << set << " no webjids");
		return;
	}
	try{
		MucGateAdapter::instance().NotifyChatSetingChange(roomid, webjids, set);
	}catch(Ice::Exception& e){
		MCE_WARN("RoomPool::ChatSetingChange--> call MucGate.NotifyChatSetingChange ERR  line:"<<__LINE__<<" err:"<<e);
	}
	catch(std::exception& e){
		MCE_WARN("RoomPool::ChatSetingChange--> call MucGate.NotifyChatSetingChange ERR  line:"<<__LINE__<<" err:"<<e.what());
	}
}
Example #4
0
int RoomPool::GetUserCount(const MucRoomIdPtr& roomid){
  IceUtil::RWRecMutex::RLock lock(_rwmutex);
  RoomInfoPtr riptr = GetRoom(roomid);
  if(riptr){
    return riptr->GetUserCount();
  }
}
Example #5
0
void BackupManagerI::removeAll(const RoomIdPtr& rid, const Ice::Current&) {
	if (rid) {
		Ice::Long hashcode = StrUtil::hashcode(roomIdToString(rid));
		RoomInfoPtr ri = ServiceI::instance().findObject<RoomInfoPtr>(ROOM_INFO, hashcode);
		if (ri) {
			ri->removeAll(rid);
		}
		_addRemoveSqlObj(rid);
	}
}
Example #6
0
MucActiveUserSeq RoomPool::GetUserByPermision(const MucRoomIdPtr& roomid, Permisions permision){
  MucActiveUserSeq ans;
  RoomInfoPtr riptr;
  IceUtil::RWRecMutex::RLock lock(_rwmutex);
  riptr = GetRoom(roomid);
  if(!riptr){
    return ans;
  }
  ans = riptr->GetActiveUserSeq(permision);
  return ans;
}
Example #7
0
OccupantSeq BackupManagerI::get(const RoomIdPtr& rid, const Ice::Current&) {
	MCE_DEBUG("call BackupManagerI::get");
	if (rid) {
		Ice::Long hashcode = StrUtil::hashcode(roomIdToString(rid));
		RoomInfoPtr ri = ServiceI::instance().locateObject<RoomInfoPtr>(ROOM_INFO, hashcode);
		if (ri) {
			MCE_DEBUG("BackupManagerI::get   --> return size:"<< ri->get(rid).size());
			return ri->get(rid);
		}
	}
	return OccupantSeq();

}
Example #8
0
void BackupManagerI::put(const OccupantPtr& o, const Ice::Current&) {
	MCE_DEBUG("BackupManagerI::put");
	if (o && o->rJid && o->rJid->rid) {
		MCE_DEBUG("BackupManagerI::put --> rjid:"<< roomJidToString(o->rJid));
		Ice::Long hashcode = StrUtil::hashcode(roomIdToString(o->rJid->rid));
		RoomInfoPtr ri = ServiceI::instance().locateObject<RoomInfoPtr>(ROOM_INFO, hashcode);
		MCE_DEBUG("BackupManagerI::put --> hashcode:"<< hashcode << " ri.size:"<<ri->get(o->rJid->rid).size());
		if (ri) {
			ri->put(o);
		}
		_addUpdateSqlObj(o);
	}
}
Example #9
0
void RoomPool::UserOnline(const MucActiveUserPtr& activeuser){
  MCE_DEBUG("RoomPool::UserOnline --> jid = " << jidToString(activeuser->jid));
  MucActiveUserPtr opaptr;
  MucActiveUserSeq presenceUsers;
  RoomInfoPtr riptr;
  bool addok = false;
	int mucstatus = 0;
  {
    //针对频繁上下线,不能上写锁。
    IceUtil::RWRecMutex::RLock lock(_rwmutex);
    riptr = GetRoom(activeuser->identity->roomid);
    if(!riptr){
			//TaskManager::instance().execute(new PageCacheNotifyTask("online", activeuser->jid->userId, activeuser->identity->roomid));
      return;
    }
		presenceUsers = riptr->GetAllActiveUsers();
		presenceUsers.push_back(activeuser);    //加自己
  }
  if(riptr){
		//如果用户是IM用户,而且房间也cache了,这样发送邀请。
		if('T' == activeuser->jid->endpoint[0]){
			MCE_DEBUG("RoomPool::UserOnline --> user is an im user and room is in cache. so send invite to it!");
			try{
				JidSeq jids;
				jids.push_back(activeuser->jid);
				MucGateAdapter::instance().InviteIMusers(activeuser->identity->roomid, jids);
			}catch(Ice::Exception& e){
      	MCE_WARN("RoomPool::UserOnline--> call MucTalkRoom.GetRoomActiveUserSeq ERR  line:"<<__LINE__<<" err:"<<e);
   	 	}
    	catch(std::exception& e){
      	MCE_WARN("RoomPool::EnterRoom --> call MucTalkRoom.GetRoomActiveUserSeq ERR  line:"<<__LINE__<<" err:"<<e.what());
    	}
			return;
		}

    //如果这个房间被cache住了,在线中心会响应这个用户的上线行为
    IceUtil::RWRecMutex::WLock lock(_rwmutex);
    addok = riptr->AddActiveUser(activeuser);
		if(addok){
			mucstatus = riptr->GetUserMucStatus(activeuser->jid->userId);
		}
  }

  if(addok && !presenceUsers.empty()){
    MucGateAdapter::instance().NotifyUserEnterRoom(activeuser, presenceUsers, mucstatus);
  }
}
Example #10
0
Ice::ObjectPtr RoomInfoFactoryI::create(Ice::Long hashcode) {
	Statement sql;
	sql << "select * from occupant_backup where hashcode = " << boost::lexical_cast<string>(hashcode).c_str();
	//MCE_DEBUG("RoomFactoryI::create --> " << sql);
	try {
#ifndef NEWARCH
		mysqlpp::Result res = QueryRunner("im_groupchat", CDbRServer).store(sql);
#else
		mysqlpp::StoreQueryResult res = QueryRunner("im_groupchat", CDbRServer).store(sql);
#endif
		MCE_DEBUG("RoomInfoFactoryI::create --> load occupant_backup from database, count=" << res.size());
		RoomInfoPtr ri = new RoomInfo();
		for (size_t i= 0; i<res.size(); ++i) {

			mysqlpp::Row row = res.at(i);

			OccupantPtr o = new Occupant();
#ifndef NEWARCH
			o->rJid = stringToRoomJid(row["rjid"].get_string());
#else
			o->rJid = stringToRoomJid(row["rjid"].c_str());
#endif
			o->fJid = new Jid();
			o->fJid->userId = (int)row["userid"];
#ifndef NEWARCH
			o->fJid->endpoint = row["endpoint"].get_string();
#else
			o->fJid->endpoint = row["endpoint"].c_str();
#endif
			o->fJid->index = (Ice::Long)row["jid_index"];

			o->aType = (Affiliation)(int)row["affiliation"];
			o->role = (RoomRole)(int)row["role"];

			ri->put(o);
		}
		return ri;
	} catch(Ice::Exception& e) {
		MCE_WARN(e << " at " << __FILE__ << ":" << __LINE__);
	} catch (std::exception& e) {
		MCE_WARN(e.what() << " at " << __FILE__ << ":" << __LINE__);
	} catch (...) {
		MCE_WARN("Unkown exception at " << __FILE__ << ":" << __LINE__);
	}

	return 0;
}
Example #11
0
void RoomPool::SendTalkMessage(const JidPtr& opuser, const MucRoomIdPtr& roomid, const string& msg){
  MCE_DEBUG("RoomPool::SendTalkMessage --> jid = " << jidToString(opuser) << " roomname = " << roomid->roomname << " msg = " << msg);
  MucActiveUserPtr opaptr;
  JidSeq presenceUsers;
	RoomInfoPtr riptr;

  {
    IceUtil::RWRecMutex::RLock lock(_rwmutex);
    riptr = GetRoom(roomid);
  }
  {
    MCE_DEBUG("RoomPool::SendTalkMessage -->GetRoom HERE");
		if(!riptr){
      GetActiveUsers(roomid);
      MCE_DEBUG("RoomPool::SendTalkMessage --> LOCATE NEW ROOM");
		}
  }

  {
  
    IceUtil::RWRecMutex::RLock lock(_rwmutex);
    if (!riptr)
      riptr = GetRoom(roomid);
		if(!riptr){
      MCE_WARN("RoomPool::SendTalkMessage --> LOCATE NEW ROOM ERROR"); 
      return;
      
		}
    MCE_DEBUG("RoomPool::SendTalkMessage -->GetRoom OK");
		opaptr = riptr->GetActiveUser(opuser);
		if(opaptr){
			presenceUsers = riptr->GetAllActiveJids();
		}else{
    	MCE_WARN("RoomPool::SendTalkMessage --> no activeuser in room.....it is so amazing pull the jid :" << jidToString(opuser) << " into the room");
			TaskManager::instance().execute(new PullLostUserTask(opuser));
		}
  }
  if(opaptr && !presenceUsers.empty()){
    MCE_DEBUG("RoomPool::SendTalkMessage --> presenceUsers.size = " << presenceUsers.size());
    MucGateAdapter::instance().NotifyGroupChat(opaptr, presenceUsers, msg);
  }
}
Example #12
0
void RoomPool::SendPrivateMsg(const JidPtr& sender, const MucUserIdentityPtr& recidentity, const string& msg){
	MCE_DEBUG("RoomPool::SendPrivateMsg --> sender = " << jidToString(sender) << " recidentity = " << mucUserIdentityToString(recidentity) << " msg = " << msg);
	RoomInfoPtr riptr;
	MucActiveUserPtr opaptr, targetptr;
	{
  	IceUtil::RWRecMutex::RLock lock(_rwmutex);
  	riptr = GetRoom(recidentity->roomid);
  	opaptr = riptr->GetActiveUser(sender);
  	if(!opaptr){
			MCE_WARN("RoomPool::SendPrivateMsg --> get sender : " << jidToString(sender) << " 'S activeuser error");
    	return;
  	}
  	targetptr = riptr->GetActiveUser(recidentity->nickname);
  	if(!targetptr){
			MCE_WARN("RoomPool::SendPrivateMsg --> get targetptr ERROR");
    	return;
  	}
	}
	MCE_DEBUG("RoomPool::SendPrivateMsg --> CALL MucGate.NotifyPrivateChat");
  MucGateAdapter::instance().NotifyPrivateChat(opaptr, targetptr->jid->userId, msg);
}
Example #13
0
RoomInfoPtr RoomPool::JoinRoom(const MucActiveUserPtr& activeuser){
  MCE_DEBUG("RoomPool::JoinRoom --> activeuser info : jid = " << jidToString(activeuser->jid) << " roomname = " << activeuser->identity->roomid->roomname << " domain = " << activeuser->identity->roomid->domain);
  RoomInfoPtr riptr;
	bool isnewroom = false;
	bool enterok = true;
	riptr = GetRoom(activeuser->identity->roomid);
	if(!riptr){
		isnewroom = true;
		riptr = CreateRoom(activeuser->identity->roomid);
	}
	if(riptr){
		if(TEMPORARY == activeuser->identity->roomid->domain){
			if(isnewroom){
				MCE_DEBUG("RoomPool::JoinRoom --> the room " << activeuser->identity->roomid->roomname << " is confrenc group and the user = "******" is the creater of the group so he is the owner");
				MucActiveUserPtr changePermisionuser = new MucActiveUser();
				changePermisionuser->identity = activeuser->identity;
				changePermisionuser->jid = activeuser->jid;
				changePermisionuser->permision = POwner;
				enterok = riptr->AddActiveUser(changePermisionuser);
			}
			else{
				MucActiveUserPtr temporary_user = riptr->GetActiveUser(activeuser->jid->userId);
				if(temporary_user){
					if(POutcast == temporary_user->permision){
						MCE_DEBUG("RoomPool::JoinRoom --> the user " << activeuser->jid->userId << " is an outcast user so ignore the request");
						return 0;
					}
					MCE_DEBUG("RoomPool::JoinRoom --> the user " << activeuser->jid->userId << " has joined the room befor  so change the permision to " << temporary_user->permision << " and add the jid " << jidToString(activeuser->jid));
					MucActiveUserPtr changePermisionuser = new MucActiveUser();
					changePermisionuser->identity = activeuser->identity;
					changePermisionuser->jid = activeuser->jid;
					changePermisionuser->permision = temporary_user->permision;
					enterok = riptr->AddActiveUser(changePermisionuser);
				}
				else{
					MCE_DEBUG("RoomPool::JoinRoom --> add activeuser for confrence.xiaonei.com jid = " << jidToString(activeuser->jid));
					enterok = riptr->AddActiveUser(activeuser);
				}
			}
		}
		else{
			enterok = riptr->AddActiveUser(activeuser);
		}
	}
	MCE_DEBUG("RoomPool::JoinRoom --> jid = " << jidToString(activeuser->jid) << " activeuser's roomname = " << activeuser->identity->roomid->roomname << " domain = " << activeuser->identity->roomid->domain << " enterok = " << enterok);

	if(enterok){
		return riptr;
	}
	return 0;
}
Example #14
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);
}
Example #15
0
MucUserIdentitySeq RoomPool::GetActiveUsers(const MucRoomIdPtr& roomid){
  MCE_DEBUG("RoomPool::GetActiveUsers --> roomname = " << roomid->roomname << " roomdomain = " << roomid->domain);
  bool hasroom = false;
  JidSeq imusers;
  MucActiveUserSeq activeusers;
  MucUserIdentitySeq ans;
  RoomInfoPtr riptr;
  {
    IceUtil::RWRecMutex::RLock lock(_rwmutex);
    riptr = GetRoom(roomid);
    if(riptr){
      hasroom = true;
      ans = riptr->GetAllUserIdentity();
    }
  }
  if(!hasroom && PERMANENT == roomid->domain){
    MCE_DEBUG("RoomPool::GetActiveUsers --> roomname = " << roomid->roomname << " pull from MucTalkRoom");
		try{
    	activeusers = MucTalkRoomAdapter::instance().GetRoomActiveUserSeq(roomid);
		}
		catch(Ice::Exception& e){
			MCE_WARN("RoomPool::GetActiveUsers --> call MucTalkRoom.GetRoomActiveUserSeq ERR  line:"<<__LINE__<<" err:"<<e);
		}
		catch(std::exception& e){
			MCE_WARN("RoomPool::GetActiveUsers --> call MucTalkRoom.GetRoomActiveUserSeq ERR  line:"<<__LINE__<<" err:"<<e.what());
		}
		if(activeusers.empty()){
			MCE_DEBUG("RoomPool::GetActiveUsers --> call MucTalkRoom.GetRoomActiveUserSeq empty result so return@@");
		  return ans;
		}
		bool checkagain = false;
		IceUtil::RWRecMutex::WLock lock(_rwmutex);
		riptr = GetRoom(roomid);
    if(riptr){
      MCE_DEBUG("RoomPool::GetActiveUsers --> after check again bool againcheck = true so only return room's all activeusers ");
      checkagain = true;
      ans = riptr->GetAllUserIdentity();
    }
    if(!checkagain){
      MCE_DEBUG("RoomPool::GetActiveUsers --> after check again bool againcheck = false we add web activeusers into server cache and send invite to imusers if have");
      bool hasaddroom = false;
      set<int> uids;
      MucActiveUserSeq::iterator it = activeusers.begin();
      for(; it != activeusers.end(); ++it){
        if((*it)->jid->endpoint[0] == 'W'){
          hasaddroom = true;
					MCE_DEBUG("RoomPool::GetActiveUsers --> PUSH ACIVEUSER INFO : jid = " << jidToString((*it)->jid) << " roomname = " << (*it)->identity->roomid->roomname << " domain = " << (*it)->identity->roomid->domain << " permision = " << (*it)->permision);
          JoinRoom((*it));
        }
        else if((*it)->jid->endpoint[0] == 'T'){
          imusers.push_back((*it)->jid);
        }
        pair<set<int>::iterator, bool > insertres = uids.insert((*it)->jid->userId);
        if(insertres.second){
          ans.push_back((*it)->identity);
        }
      }
      if(!hasaddroom){
        CreateRoom(roomid);
      }
    }
  }
  if(!imusers.empty()){
    MCE_DEBUG("RoomPool::GetActiveUsers send invite to imusers : size = " << imusers.size());
    MucGateAdapter::instance().InviteIMusers(roomid, imusers);
  }
  MCE_DEBUG("RoomPool::GetActiveUsers --> roomname = " << roomid->roomname << " all activeusers.size = " << ans.size());
	for(MucUserIdentitySeq::iterator logit = ans.begin(); logit != ans.end(); ++logit){
  	MCE_DEBUG("RoomPool::GetActiveUsers --> activeuser info : roomname = " << (*logit)->roomid->roomname << " nickname = " << (*logit)->nickname);
	}
  return ans;
}
Example #16
0
void RoomPool::EnterRoom(const MucActiveUserPtr& activeuser){
  MCE_DEBUG("RoomPool::EnterRoom --> activeuser info : jid = " << jidToString(activeuser->jid) << " roomname = " << activeuser->identity->roomid->roomname << " domain = " << activeuser->identity->roomid->domain);

  RoomInfoPtr riptr;
  MucActiveUserPtr opaptr;
  MucActiveUserSeq presenceUsers;
  bool hasroom = true;
	int mucstatus = 0;
	bool enterok = false;
  if(TEMPORARY == activeuser->identity->roomid->domain){
		//临时房间
		{
    	MCE_DEBUG("RoomPool::EnterRoom --> domain == " << TEMPORARY);
    	IceUtil::RWRecMutex::WLock lock(_rwmutex);
			riptr = JoinRoom(activeuser);
			if(riptr){
				//临时房间用户可能会改变他的权限。
				opaptr = riptr->GetActiveUser(activeuser->jid);
				if(opaptr){
					enterok = true;
				}
			}
		}
		if(!enterok){
			try{
				MCE_DEBUG("RoomPool::EnterRoom --> CALL MucGate.NotifyNicknameError jid:" << jidToString(activeuser->jid) << " room:" << mucRoomIdToString(activeuser->identity->roomid));
				MucGateAdapter::instance().NotifyNicknameError(activeuser->identity->roomid, activeuser->jid);
			}
			catch(Ice::Exception& e){
				MCE_WARN("RoomPool::EnterRoom --> call MucGate.NotifyNicknameError ERR  line:"<<__LINE__<<" err:"<<e);
			}
			catch(std::exception& e){
				MCE_WARN("RoomPool::EnterRoom --> call MucGate.NotifyNicknameError ERR  line:"<<__LINE__<<" err:"<<e.what());
			}
			return;
		}
		/*
		//临时房间聊天发起者多副本同步,要向其他副本发送邀请
		JidSeq imjids;
		try{
			MCE_DEBUG("RoomPool::EnterRoom --> CALL OnlineCenter.getUserJids for invite the other jids. userid = " << activeuser->jid->userId);
			imjids = OnlineCenterAdapter::instance().getUserJids(activeuser->jid->userId, 4);
		}
		catch(Ice::Exception& e){
			MCE_WARN("RoomPool::EnterRoom --> call OnlineCenter.getUserJids ERR  line:"<<__LINE__<<" err:"<<e);
		}
		catch(std::exception& e){
			MCE_WARN("RoomPool::EnterRoom --> call OnlineCenter.getUserJids ERR  line:"<<__LINE__<<" err:"<<e.what());
		}
		if(imjids.empty()){
			return;
		}
		for(JidSeq::iterator jit = imjids.begin(); jit != imjids.end(); ++jit){
			if(equal((*jit), activeuser->jid)){
				imjids.erase(jit);
				MCE_DEBUG("RoomPool::EnterRoom --> erase the activeuser->jid from want to invite");
				break;
			}
		}
		if(!imjids.empty()){
			MCE_DEBUG("RoomPool::EnterRoom --> invite the user : "******"'s other avatar into the room");
			try{
				MucGateAdapter::instance().InviteIMusers(activeuser->identity->roomid, imjids);
			}
			catch(Ice::Exception& e){
				MCE_WARN("RoomPool::EnterRoom --> call MucGate.InviteImUsers ERR  line:"<<__LINE__<<" err:"<<e);
			}
			catch(std::exception& e){
				MCE_WARN("RoomPool::EnterRoom --> call OnlineCenter.InviteImUsers ERR  line:"<<__LINE__<<" err:"<<e.what());
			}
		}
		*/
  }
  else if(PERMANENT == activeuser->identity->roomid->domain){
		opaptr = activeuser;
    MCE_DEBUG("RoomPool::EnterRoom --> domain == " << PERMANENT);
    {
      IceUtil::RWRecMutex::RLock lock(_rwmutex);
      riptr = GetRoom(activeuser->identity->roomid);
    }
    if(riptr){
			//如果房间存在,直接加人
      MCE_DEBUG("RoomPool::EnterRoom --> riptr is not null so call it AddActiveUser function");
      IceUtil::RWRecMutex::WLock lock(_rwmutex);
      enterok = riptr->AddActiveUser(activeuser);
    }
    else{
      MCE_DEBUG("RoomPool::EnterRoom --> riptr is null .No " << activeuser->identity->roomid->roomname << " in cache pull from MucTalkRoom");
      hasroom = false;
      JidSeq imusers;
      MCE_DEBUG("RoomPool::EnterRoom --> CALL MucTalkRoomAdapter.GetRoomActiveUserSeq roomname = " << activeuser->identity->roomid->roomname);
      try{
        presenceUsers = MucTalkRoomAdapter::instance().GetRoomActiveUserSeq(activeuser->identity->roomid);
      }
      catch(Ice::Exception& e){
        MCE_WARN("RoomPool::EnterRoom --> call MucTalkRoom.GetRoomActiveUserSeq ERR  line:"<<__LINE__<<" err:"<<e);
      }
      catch(std::exception& e){
        MCE_WARN("RoomPool::EnterRoom --> call MucTalkRoom.GetRoomActiveUserSeq ERR  line:"<<__LINE__<<" err:"<<e.what());
      }
      {
        IceUtil::RWRecMutex::WLock lock(_rwmutex);
        bool againcheck = false;
        riptr = GetRoom(activeuser->identity->roomid);
        if(riptr){
          MCE_DEBUG("RoomPool::EnterRoom --> after check again bool againcheck = true so it means the users has pull hera already so only add it");
          againcheck = true;
					hasroom = true;
          enterok = riptr->AddActiveUser(activeuser);
        }
        if(!againcheck){
          MCE_DEBUG("RoomPool::EnterRoom --> after check again  bool againcheck = false so push the web presenceUsers(get from MucTalkRoom) into room and send invite to IM users");
          bool hasaddroom = false;
          MucActiveUserSeq::iterator it = presenceUsers.begin();
          for(; it != presenceUsers.end();){
            if((*it)->jid->endpoint[0] == 'W'){
              hasaddroom = true;
              riptr = JoinRoom((*it));
							++it;
            }
						else if(equal(activeuser->jid, (*it)->jid)){
							MCE_DEBUG("RoomPool::EnterRoom --> the activeuser self enter room");
							//第三方客户端可能会起不同的名字所以在这里要加入房间的参数activeuser 并且修改这个seq里面的元素。
							hasaddroom = true;
							riptr = JoinRoom(activeuser);
							(*it) = activeuser;
							++it;
						}
            else if((*it)->jid->endpoint[0] == 'T'){
              imusers.push_back((*it)->jid);
							//对于客户端用户,我们发送邀请。所以,它并不在房间内,我们要从广播用户内删除他们。
							it = presenceUsers.erase(it);
            }
          }
          if(!hasaddroom){
            riptr = CreateRoom(activeuser->identity->roomid);
          }
					if(riptr){
						//判断拉进来的用户里面有没有自己
						opaptr = riptr->GetActiveUser(activeuser->jid);
						if(opaptr){
							enterok = true;
						}
					}
        }
      }
      if(enterok && !imusers.empty()){
        MCE_DEBUG("RoomPool::EnterRoom --> send invite to imiusers size = " << imusers.size());
        MucGateAdapter::instance().InviteIMusers(activeuser->identity->roomid, imusers);
      }
    }
  }
	
	if(!enterok){
		MCE_DEBUG("RoomPool::EnterRoom --> jid = " << jidToString(activeuser->jid) << " enterok = false return");
		return;
	}
	
  if(hasroom){
    IceUtil::RWRecMutex::RLock lock(_rwmutex);
    presenceUsers = riptr->GetAllActiveUsers();
  }
  if(opaptr && !presenceUsers.empty()){
    MCE_DEBUG("RoomPool::EnterRoom --> jid = " << jidToString(activeuser->jid) << " OK");
		for(MucActiveUserSeq::iterator logit = presenceUsers.begin(); logit != presenceUsers.end(); ++logit){
			MCE_DEBUG("RoomPool::EnterRoom --> presenceUser : info " << jidToString((*logit)->jid) << " room : " << mucUserIdentityToString((*logit)->identity) << " permision = " << (*logit)->permision);
		}
		if(PERMANENT == activeuser->identity->roomid->domain && riptr){
    	IceUtil::RWRecMutex::RLock lock(_rwmutex);
			mucstatus = riptr->GetUserMucStatus(activeuser->jid->userId);
		}
    MucGateAdapter::instance().NotifyUserEnterRoom(opaptr, presenceUsers, mucstatus);
  }
}