Ejemplo n.º 1
0
void MiniGroupWriterAdapter::run() {
  while (true) {
    MyUtil::IntSeq userIds;
    MyUtil::LongSeq miniGroupIds;
    {
      IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_mutex);
      if (_userIdSet.empty() && _miniGroupIdSet.empty()) {
        _mutex.wait();
      }
      userIds.insert(userIds.end(), _userIdSet.begin(), _userIdSet.end());
      _userIdSet.clear();
      miniGroupIds.insert(miniGroupIds.end(), _miniGroupIdSet.begin(), _miniGroupIdSet.end());
      _miniGroupIdSet.clear();
    }
    if (!userIds.empty()) {
      try {
        getMiniGroupWriterPrx(0)->reloadUsers(userIds);
      } catch(Ice::Exception& e) {
        MCE_WARN("[MiniGroupWriterAdapter::run] reloadUsers size = " << userIds.size());
      }
    }
    if (!miniGroupIds.empty()) {
      try {
        getMiniGroupWriterPrx(0)->reloadMiniGroups(miniGroupIds);
      } catch(Ice::Exception& e) {
        MCE_WARN("[MiniGroupWriterAdapter::run] reloadMiniGroups size = " << miniGroupIds.size());
      }
    }
  }
}
Ejemplo n.º 2
0
MyUtil::Int2IntMap OfferFriendsUtil::getFriendCountBatch(const MyUtil::IntSeq& ids) {
        MyUtil::Int2IntMap result;
        if (ids.empty()) {
                return result;
        }
	return FriendCountCacheAdapter::instance().getFriendCounts(ids);
}
Ejemplo n.º 3
0
MyUtil::Int2IntSeqMap OfferFriendsUtil::getFriendSeqBatch(const MyUtil::IntSeq& ids) {
        Int2IntSeqMap result;
        if (ids.empty()) {
                return result;
        }
        return BuddyByIdCacheAdapter::instance().getFriendLists(ids);
}
MyUtil::Int2IntMap SocialGraphBuddyByIdAdapter::getFriendCounts(const MyUtil::IntSeq& hostIds) {
  if(hostIds.empty()) {
    return MyUtil::Int2IntMap();
  }  else {
    try {
      return getProxy(hostIds.at(0))->getFriendCounts(hostIds);
    } catch(...) {
      return MyUtil::Int2IntMap();
    }
  } 
}
Ejemplo n.º 5
0
map<string, string> UseImNotifyTask::parameters(){
	map<string, string> paras;

	paras["method"] = "notifications.send";
	paras["session_key"] = boost::lexical_cast<string>(_userid);
	//paras["api_key"] = "ffa4add0b30141aa9eb9a8f1af34a8c3";
	//paras["call_id"] = boost::lexical_cast<string>(time(NULL));
	//paras["v"] = "1.0";
	//paras["format"] = "xml";
  MyUtil::IntSeq ids;
	try{
	 ids = BuddyByOnlineTimeCacheAdapter::instance().getFriendList(_userid, 20);
	}
	catch(Ice::Exception& e){
		MCE_WARN("UseImNotifyTask::parameters-->BuddyByOnlineTimeCacheAdapter::getFriendList-->" << e);
		}
	if(ids.empty()) {
	 return map<string, string>();
	}
	MCE_INFO("UseImNotifyTask::parameters --> " << _userid << " " << ids.size());
	ostringstream buddyids;
	for(size_t i = 0; i < ids.size(); ++i) {
	 //  int c = ids.size() < 10? ids.size(): 10;
	 //  for(size_t i = 0; i < c; ++i) {
	 if(i) {
		 buddyids << ",";
	 }
	 buddyids << ids.at(i);
	}
	paras["to_ids"] = buddyids.str();

	ostringstream msg[3];

	msg[0] << "<xn:name uid=\""<<_userid<<"\" linked=\"true\"/>悄悄安装了<a href=\"http://im.renren.com/desktop.html?answer1\">人人桌面</a>,能定时启动游戏,采摘你的果实,升级更快了!| <a href=\"http://im.renren.com/desktop/ver19/rrsetup.exe?answer1\">赶紧安装不能落后!</a>";
	
	msg[1] << "<xn:name uid=\""<<_userid<<"\" linked=\"true\"/>抢先体验了<a href=\"http://im.renren.com/desktop.html?settime2\">人人桌面</a>,留言提醒、快速回复、好友聊天更快更稳定! | <a href=\"http://im.renren.com/desktop/ver19/rrsetup.exe?settime2\">快来安装吧</a>";
	
	msg[2] << "<xn:name uid=\""<<_userid<<"\" linked=\"true\"/>用<a href=\"http://im.renren.com/desktop.html?onemin3\">人人桌面</a>登录了人人网,TA不开网页,就能一键登录、隐身上线、定时玩游戏! | <a href=\"http://im.renren.com/desktop/ver19/rrsetup.exe?onemin3\">我也要安装</a>";
	
	paras["notification"] = msg[abs(_userid)%3].str();
/*	paras["sig"] = makeSig(paras);


	string path = "http://api.xiaonei.com/server/restserver.do";
	try{
		RestMediatorAdapter::instance().restRequest(id(), _userid, path, paras);
	}catch(Ice::Exception& e){
		MCE_WARN("UseImNotifyTask::handle --> invoke RestMediatorAdapter error" << e);
	}*/
	return paras;
}
Ejemplo n.º 6
0
MyUtil::ObjectResultPtr FriendsRecentPhotosPreloaderFactory::create(const MyUtil::IntSeq& ids) {
    MCE_INFO("[FriendsRecentPhotosPreloaderFactory::create] ids.size = " << ids.size());
    MyUtil::ObjectResultPtr result = new MyUtil::ObjectResult;
    if (ids.empty()) {
        return result;
    }
    vector<UserPhotosInfoPtr> resultPtrs;
    //此处一定要注意,ids并不一定属于同一个尾号
    map<int, vector<int> > seperatedIds = xce::mngp::DBUtil<int>::seperateIdsByMod<int>(TABLE_MOD, ids);
    for (map<int, vector<int> >::const_iterator itv = seperatedIds.begin(); itv != seperatedIds.end(); ++itv) {
        Statement sql;
        string tableName = TABLE_NAME + "_" + boost::lexical_cast<string>(itv->first % TABLE_MOD);
        sql << "select " << COLUMN_USERID << ", " << COLUMN_PHOTOS << " from " << tableName << " where "
            << COLUMN_USERID << " in " << xce::mngp::DBUtil<int>::getIdsStr<int>(itv->second);
        QueryRunner(DB_SOURCE, CDbRServer, tableName).query(sql, UserPhotosInfoResultHandlerI(resultPtrs));
    }
    return UserPhotosInfo::changeToUserPhotosInfoMap(resultPtrs);
}
Ejemplo n.º 7
0
map<int,int> OfferFriendsUtil::getViewCountMap(const MyUtil::IntSeq& ids){
	map<int,int> res;
        if( ids.empty() ){
		return res;
	}
	ostringstream idstr;
        MyUtil::IntSeq::const_iterator it = ids.begin();
	idstr << "(" << *it;
        for ( ++it; it!=ids.end(); ++it) {
		idstr << ", " << *it;
        }
	idstr << ")";

	Statement sql;
	sql	<< "SELECT id,viewcount FROM view_count"
		<< " WHERE id IN " << idstr.str();

	QueryRunner("user_view_count_preloader", CDbRServer).query( sql, ViewCountHandler(res) );

        return res;
}
Ejemplo n.º 8
0
MyUtil::Int2IntSeqMap BuddyByAddTimeCacheAdapter::getFriendLists(const MyUtil::IntSeq& ids){
	if (ids.empty()){
		return MyUtil::Int2IntSeqMap();
	}
	size_t numCluster_sizeT = getCluster();
	int numCluster = (int)numCluster_sizeT;
	if (numCluster < 0) {
		MCE_WARN("[BuddyByAddTimeCacheAdapter::getFriendLists] this should not be seen! Why cluster=" << numCluster_sizeT << " ???" );
		return MyUtil::Int2IntSeqMap();
	}
	if (numCluster == 0 || numCluster == 1) {
		try {
			return getProxy(ids.at(0))->getFriendLists(ids);
		} catch (...) {
			return MyUtil::Int2IntSeqMap();
		}
	} else {
                vector< vector<int> > seperatedIds;
                seperatedIds.resize( numCluster );
                for( MyUtil::IntSeq::const_iterator it = ids.begin(); it
                                != ids.end(); ++it ){
                        seperatedIds.at( *it % numCluster ).push_back( *it );
                }
                MyUtil::Int2IntSeqMap result;
                for (int posCluster = 0; posCluster < numCluster; ++posCluster) {
                        MyUtil::Int2IntSeqMap someResult;
                        if( seperatedIds.at(posCluster).size() > 0 ){
                                try {
                                        someResult = getProxy(posCluster)->getFriendLists(seperatedIds.at(posCluster));
                                } catch (...) {
                                        MCE_WARN( "BuddyByAddTimeCacheAdapter::getFriendLists from Proxy(" << posCluster << ") handle unknown exception." );
                                }
                                result.insert( someResult.begin(), someResult.end() );
                        }
                }
                return result;
	}
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
AvatarMap OnlineCenterAdapter::getUsersAvatars(const MyUtil::IntSeq& ids, int onlineType) {
	if(ids.empty()){
		return AvatarMap();
	}
	return getManager(ids.at(0))->getUsersAvatars(ids, onlineType);
}
Ejemplo n.º 11
0
UserOnlineTypeSeq OnlineCenterAdapter::getUsersOnlineTypeSeq(const MyUtil::IntSeq& ids, int timeout){
	if(ids.empty()){
		return UserOnlineTypeSeq();
	}
	return getManager(ids.at(0), timeout)->getUsersOnlineTypeSeq(ids);
}