Exemplo n.º 1
0
void NoticePipe::handle(const ObjectSeq& objs){
	MessageSeq msgs;
	IntSeq ids;

	for (size_t i = 0; i < objs.size(); ++i) {
		MessagePtr m = MessagePtr::dynamicCast(objs.at(i));
		msgs.push_back(m);
		ids.push_back(m->to->userId);
	}
	JidSeqMap jmap;
	try{
		//jmap = OnlineCenterAdapter::instance().getUsersJids(ids);
		jmap = TalkFunStateAdapter::instance().getUsersJids(ids);
	}catch(Ice::Exception& e){
		//MCE_WARN("NoticePipe::handle --> call OnlineCenterAdapter.getUsersJids error : " << e);
		MCE_WARN("NoticePipe::handle --> call TalkFunStateAdapter.getUsersJids error : " << e);
	}
	MessageSeq res;
	for (size_t i = 0; i < msgs.size(); ++i) {
		JidSeqMap::iterator it = jmap.find(msgs.at(i)->to->userId);
		if (it == jmap.end()) {
			continue;
		}
		for (size_t j = 0; j < it->second.size(); ++j) {
			if (it->second.at(j)->endpoint.size() > 1
					&& it->second.at(j)->endpoint[0] == 'T') {
				MessagePtr m = new Message();
				m->from = new Jid();
				m->from->userId = -1;
				m->from->endpoint = "appnotice.talk.xiaonei.com";
				m->from->index = -1;
				m->to = it->second.at(j);
				m->type = msgs.at(i)->type;
				m->msg = msgs.at(i)->msg;

				res.push_back(m);
			}

		}
	}
	if (!res.empty()) {
		MCE_INFO("NoticePipe::handle --> Notice size:"<<res.size());
		try{
			TalkDeliverAdapter::instance().deliver(res);
		}catch(Ice::Exception& e){
			MCE_WARN("NoticePipe::handle --> call TalkDeliverAdapter.deliver error : " << e);
		}
	}
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
void FeedReplyPipe::handle(){
	FeedReplyToMessagConverter converter;
	TimeStat ts;
	float totalwait = 0.0;
	FeedReplyWithTargetSeq objs;
	WTransitManagerI::instance().SwapFeedReplySeq(objs);
	if(objs.empty()){
		return;
	}
	//for(size_t x = 0; x < objs.size(); ++x){
		//FeedReplyWithTargetPtr reply = FeedReplyWithTargetPtr::dynamicCast(objs.at(x));
		//FeedReplyWithTargetPtr reply = objs.at(x);
		//totalwait += reply->latets.getTime();
	//}
	MessageSeq msgs;
	for (size_t x = 0; x < objs.size(); ++x) {
		//FeedReplyWithTargetPtr reply = FeedReplyWithTargetPtr::dynamicCast(objs.at(x));
		FeedReplyWithTargetPtr reply = objs.at(x);
		converter.setData(reply->replyData);
		if(reply->replyData->actor == 257876975 || reply->replyData->actor == 238489851){
			//MCE_DEBUG(reply->replyData->actor << " " << reply->replyData->xml);
		}
//		MyUtil::IntSeq target = reply->getTarget();
		MCE_DEBUG(" FeedReplyPipe::handle --> feed->target.size = "<< reply->target.size());
		JidSeqMap jmap;
	
		try {
			//jmap = OnlineCenterAdapter::instance().getUsersJids(reply->target);
			jmap = TalkFunStateAdapter::instance().getUsersJids(reply->target, 22);
		} catch (Ice::Exception& e) {
			MCE_WARN("FeedReplyPipe::handle-->TalkFunStateAdapter::getUsersJids-->" << reply->replyData->actor << " " << reply->target.size() << " "<<e);
		} catch (std::exception& e) {
			MCE_WARN("FeedReplyPipe::handle --> online center err: " << reply->target.size() << " "<<e.what());
		}
		if (jmap.empty()) {
			MCE_DEBUG("FeedReplyPipe::handle --> no friend online  ");
			continue;
		}
		MCE_DEBUG("FeedReplyPipe::handle --> jmap.size = "<<jmap.size());
		
		for (size_t i = 0; i < reply->target.size(); ++i) {
			JidSeqMap::const_iterator it = jmap.find(reply->target.at(i));
			if (it == jmap.end()) {
				MCE_DEBUG("FeedReplyPipe::handle --> can not find jmap feed->target(i)="<<reply->target.at(i));
				continue;
			}
			for (size_t j = 0; j < it->second.size(); ++j) {
				MessagePtr msg;
				if ( (!it->second.at(j)->endpoint.empty()) ){
					if( it->second.at(j)->endpoint[0] == 'T' ){
					  //MCE_DEBUG("FeedReplyPipe::handle-->SEND REPLY source=" << reply->replyData->source << " actor=" << reply->replyData->actor << " replyid=" << reply->replyData->replyId << " to userid=" << it->second.at(j)->userId);
						msg = converter.getToTalkMessage(it->second.at(j));
					}
					if(msg){
						msgs.push_back(msg);
					}
				}
			}
		}
	}
	if (!msgs.empty()) {
		try{
			TalkDeliverAdapter::instance().deliver(msgs);
		}catch(Ice::Exception& e){
			MCE_WARN("FeedReplyPipe::handle --> TalkDeliverAdapter::deliver--> error : " << e);
		}
	}
	MONITOR("SignForTimeuse::WTransit::FeedReplyPipe::handle-->" << ts.getTime() << "|" << "count" << objs.size());
}