//-------------------------------------------------------------------------------- void RemovePipe::handle(const ObjectSeq& seq) { MCE_INFO("RemovePipe::handle --> thread_id = " << pthread_self() << " seq size:" << seq.size()); if (seq.empty()) { return; } std::set<std::string> removeKeySet; std::size_t si = seq.size(); int j = 0; timeval beg, end; gettimeofday(&beg, NULL); for (size_t i = 0; i < seq.size(); ++i) { RemoveFeedFromDBKeyPtr st = RemoveFeedFromDBKeyPtr::dynamicCast(seq.at(i)); if (st->indexSeq.empty()) { continue; } gettimeofday(&end, NULL); float timeuse=1000000*(end.tv_sec-beg.tv_sec)+end.tv_usec-beg.tv_usec; timeuse/=1000; MCE_INFO("RemovePipe::handle --> execute task. source:" << st->indexSeq[0]->source << " type:" << st->indexSeq[0]->stype << " i:" << i << " seq_size:" << si << " time:" << timeuse); TaskManager::instance().execute(new RemoveFeedTask(st->indexSeq)); gettimeofday(&beg, NULL); struct timeval tv = { 0, 100 * 1000 }; select(0, NULL, NULL, NULL, &tv); } MCE_INFO("RemovePipe::handle --> loop end. last dup:" << j); }
void PostPipe::handle(const ObjectSeq& seq) { if (seq.empty()) { return; } else { MCE_DEBUG("PostPipe::handle --> objectseq size = " <<seq.size()); } MessageSeq mseq; for (size_t i = 0; i < seq.size(); ++i) { mseq.push_back(MessagePtr::dynamicCast(seq.at(i))); } try { MCE_DEBUG("start to deliver --> toid:"<<mseq.at(0)->to->userId); WTalkProxyManagerI::instance().getAccessServerOneway(getName())->deliver(mseq); MCE_DEBUG("end deliver --> toid:"<<mseq.at(0)->to->userId); } catch(Ice::Exception& e) { MCE_WARN("PostPipe::handle --> deliver err:"<<e<<" to endpoint:"<< mseq.at(0)->to); } }
//-------------------------------------------------------------------------------- void VertifyPipe::handle(const ObjectSeq& seq) { //MCE_INFO("VertifyPipe::handle --> thread_id = " << pthread_self()); if (seq.empty()) { return; } else { //MCE_DEBUG("VertifyPipe::handle --> objectseq size = " <<seq.size()); } VerifySeq vSeq; IntSeq needNotVerifyUsers; for (size_t i = 0; i < seq.size(); ++i) { MessagePtr m = MessagePtr::dynamicCast(seq.at(i)); //MCE_INFO("m->from = " << m->from->userId << " m->to = " << m->to->userId); if( (m->type != MESSAGE && m->type != OFFLINE_MESSAGE) || (m->from->userId == 365734329 || m->to->userId == 365734329) ){//客服ID,不检查好友。 //MCE_INFO("VertifyPipe::handle --> m->from = " << m->from << " m->to = " << m->to); needNotVerifyUsers.push_back(i); continue; } VerifyPtr v = new Verify(); v->from = m->from->userId; v->to = m->to->userId; /*if(MESSAGE != m->type){ v->to = v->from; }*/ v->type = m->type; /* if (v->type == SYSTEM_MESSAGE) { v->sysMsgType = m->from->endpoint; }*/ v->index = i; vSeq.push_back(v); } MyUtil::IntSeq indexSeq; try{ indexSeq = TalkRightAdapter::instance().batchVerify(getIndex(), vSeq); }catch(Ice::Exception& e){ MCE_WARN("VertifyPipe::handle-->TalkRightAdapter::batchVerify-->" << e); } indexSeq.insert(indexSeq.end(), needNotVerifyUsers.begin(), needNotVerifyUsers.end()); //MCE_DEBUG("VertifyPipe::handle -->indexSeq size:"<<indexSeq.size()); for (size_t i = 0; i < indexSeq.size(); ++i) { MessagePtr m = MessagePtr::dynamicCast(seq.at(indexSeq.at(i))); //MCE_DEBUG("VertifyPipe::handle --> "<<m->to->index); if (m->to->index == 0 || m->to->index == 2 || m->to->index >1) { //MCE_DEBUG("VertifyPipe::handle --> endpoint:"<<m->to->endpoint); PipePool::instance().push(m->to->endpoint, 0, m); } } }
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); } } }
//-------------------------------------------------------------------------------- void PostPipe::handle(const ObjectSeq& seq) { if (seq.empty()) { return; } MessageSeq mseq; for (size_t i = 0; i < seq.size(); ++i) { mseq.push_back(MessagePtr::dynamicCast(seq.at(i))); } try { MucDeliverManagerI::instance().getProxyServerOneway(mseq.at(0)->to)->deliver(mseq); } catch(Ice::Exception& e) { MCE_WARN("PostPipe::handle --> deliver err:"<<e<<" to endpoint:"<< mseq.at(0)->to); } MCE_DEBUG(__FUNCTION__ << " --> deliver size="<<mseq.size()); }
void PostPipe::handle(const ObjectSeq& seq) { //MCE_INFO("PostPipe::handle --> thread_id = " << pthread_self()); if (seq.empty()) { return; } else { //MCE_DEBUG("PostPipe::handle --> objectseq size = " <<seq.size()); } //MCE_DEBUG("PostPipe::handle --> size:" << seq.size()); MessageSeq mseq; for (size_t i = 0; i < seq.size(); ++i) { mseq.push_back(MessagePtr::dynamicCast(seq.at(i))); } try { if((mseq.at(0)->to->endpoint[0] == 'T') || (mseq.at(0)->to->endpoint[0] == 'W') || (mseq.at(0)->to->endpoint[0] == 'P')){ DeliverManagerI::instance().getProxyServerOneway(mseq.at(0)->to)->deliver(mseq); } } catch(Ice::Exception& e) { MCE_WARN("PostPipe::handle -->ProxyAdapter::delivere-->"<<e<<" to endpoint:"<< mseq.at(0)->to); } }