本文整理汇总了C++中mercury::Channel::send方法的典型用法代码示例。如果您正苦于以下问题:C++ Channel::send方法的具体用法?C++ Channel::send怎么用?C++ Channel::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mercury::Channel
的用法示例。
在下文中一共展示了Channel::send方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendToClient
//-------------------------------------------------------------------------------------
bool Proxy::sendToClient(bool expectData)
{
if(!clientMailbox())
return false;
Mercury::Channel* pChannel = clientMailbox()->getChannel();
if(!pChannel)
return false;
if(expectData)
{
if(pChannel->bundles().size() == 0)
{
WARNING_MSG("Proxy::sendToClient: no data!\n");
return false;
}
}
{
// 如果数据大量阻塞发不出去将会报警
AUTO_SCOPED_PROFILE("sendToClient");
pChannel->send();
}
return true;
}
示例2: sync
//-------------------------------------------------------------------------------------
void DebugHelper::sync()
{
lockthread();
if(hasBufferedLogPackets_ == 0)
{
unlockthread();
return;
}
if(Mercury::Address::NONE == messagelogAddr_)
{
if(hasBufferedLogPackets_ > g_kbeSrvConfig.tickMaxBufferedLogs())
{
clearBufferedLog();
}
canLogFile_ = true;
unlockthread();
return;
}
Mercury::Channel* pMessagelogChannel = pNetworkInterface_->findChannel(messagelogAddr_);
if(pMessagelogChannel == NULL)
{
if(hasBufferedLogPackets_ > g_kbeSrvConfig.tickMaxBufferedLogs())
{
clearBufferedLog();
}
canLogFile_ = true;
unlockthread();
return;
}
int8 v = Mercury::g_trace_packet;
Mercury::g_trace_packet = 0;
uint32 i = 0;
size_t totalLen = 0;
while(!bufferedLogPackets_.empty())
{
if(i++ >= g_kbeSrvConfig.tickMaxSyncLogs() || totalLen > (PACKET_MAX_SIZE_TCP * 10))
break;
Mercury::Bundle* pBundle = bufferedLogPackets_.front();
bufferedLogPackets_.pop();
totalLen += pBundle->currMsgLength();
pMessagelogChannel->send(pBundle);
--hasBufferedLogPackets_;
}
Mercury::g_trace_packet = v;
canLogFile_ = false;
unlockthread();
}
示例3: sync
//-------------------------------------------------------------------------------------
void DebugHelper::sync()
{
if(bufferedLogPackets_.size() == 0)
return;
if(Mercury::Address::NONE == messagelogAddr_)
{
if(bufferedLogPackets_.size() > g_kbeSrvConfig.tickMaxBufferedLogs())
{
clearBufferedLog();
}
return;
}
Mercury::Channel* pMessagelogChannel = pNetworkInterface_->findChannel(messagelogAddr_);
if(pMessagelogChannel == NULL)
{
if(bufferedLogPackets_.size() > g_kbeSrvConfig.tickMaxBufferedLogs())
{
clearBufferedLog();
}
return;
}
int8 v = Mercury::g_trace_packet;
Mercury::g_trace_packet = 0;
uint32 i = 0;
size_t totalLen = 0;
std::list< Mercury::Bundle* >::iterator iter = bufferedLogPackets_.begin();
for(; iter != bufferedLogPackets_.end();)
{
if(i++ >= g_kbeSrvConfig.tickMaxSyncLogs() || totalLen > (PACKET_MAX_SIZE_TCP * 10))
break;
totalLen += (*iter)->currMsgLength();
pMessagelogChannel->send((*iter));
bufferedLogPackets_.erase(iter++);
}
Mercury::g_trace_packet = v;
}
示例4: update
//-------------------------------------------------------------------------------------
void Witness::update()
{
SCOPED_PROFILE(CLIENT_UPDATE_PROFILE);
if(pEntity_ == NULL)
return;
if(!pEntity_->getClientMailbox())
return;
Mercury::Channel* pChannel = pEntity_->getClientMailbox()->getChannel();
if(!pChannel)
return;
{
// 如果数据大量阻塞发不出去将会报警
AUTO_SCOPED_PROFILE("updateClientSend");
pChannel->send();
}
}
示例5: handleTimeout
int ChannelClientApp::handleTimeout( Mercury::TimerID id, void * arg )
{
ServerInterface::msg1Args & args =
ServerInterface::msg1Args::start( pChannel_->bundle() );
args.traits = pChannel_->traits();
args.seq = outSeq_++;
args.data = 0;
if (outSeq_ == numToSend_)
{
ServerInterface::disconnectArgs & args =
ServerInterface::disconnectArgs::start( pChannel_->bundle() );
args.seq = outSeq_;
this->stopTimer();
pChannel_->isIrregular( true );
}
pChannel_->send();
return 0;
}
示例6: sync
//-------------------------------------------------------------------------------------
void DebugHelper::sync()
{
if(bufferedLogPackets_.size() == 0)
return;
if(messagelogAddr_.isNone())
{
if(bufferedLogPackets_.size() > 128)
{
ERROR_MSG("DebugHelper::sync: can't found messagelog. packet size=%u.\n", bufferedLogPackets_.size());
clearBufferedLog();
}
return;
}
int8 v = Mercury::g_trace_packet;
Mercury::g_trace_packet = 0;
Mercury::Channel* pChannel = pNetworkInterface_->findChannel(messagelogAddr_);
if(pChannel == NULL)
{
if(bufferedLogPackets_.size() > 1024)
{
messagelogAddr_.ip = 0;
messagelogAddr_.port = 0;
WARNING_MSG("DebugHelper::sync: is no use the messagelog, packet size=%u.\n",
bufferedLogPackets_.size());
clearBufferedLog();
}
Mercury::g_trace_packet = v;
return;
}
if(bufferedLogPackets_.size() > 0)
{
if(bufferedLogPackets_.size() > 32)
{
WARNING_MSG("DebugHelper::sync: packet size=%u.\n", bufferedLogPackets_.size());
}
int i = 0;
size_t totalLen = 0;
std::list< Mercury::Bundle* >::iterator iter = bufferedLogPackets_.begin();
for(; iter != bufferedLogPackets_.end();)
{
if(i++ >= 32 || totalLen > (PACKET_MAX_SIZE_TCP * 10))
break;
totalLen += (*iter)->currMsgLength();
pChannel->send((*iter));
Mercury::Bundle::ObjPool().reclaimObject((*iter));
bufferedLogPackets_.erase(iter++);
}
}
Mercury::g_trace_packet = v;
}