本文整理汇总了C++中network::Bundle::pCurrPacket方法的典型用法代码示例。如果您正苦于以下问题:C++ Bundle::pCurrPacket方法的具体用法?C++ Bundle::pCurrPacket怎么用?C++ Bundle::pCurrPacket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network::Bundle
的用法示例。
在下文中一共展示了Bundle::pCurrPacket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateComponentInfos
//-------------------------------------------------------------------------------------
bool Components::updateComponentInfos(const Components::ComponentInfos* info)
{
// 不对其他machine做处理
if(info->componentType == MACHINE_TYPE)
{
return true;
}
if (!lookupLocalComponentRunning(info->pid))
return false;
Network::EndPoint epListen;
epListen.socket(SOCK_STREAM);
if (!epListen.good())
{
ERROR_MSG("Components::updateComponentInfos: couldn't create a socket\n");
return true;
}
epListen.setnonblocking(true);
while(true)
{
fd_set frds, fwds;
struct timeval tv = { 0, 300000 }; // 100ms
FD_ZERO( &frds );
FD_ZERO( &fwds );
FD_SET((int)epListen, &frds);
FD_SET((int)epListen, &fwds);
if(epListen.connect(info->pIntAddr->port, info->pIntAddr->ip) == -1)
{
int selgot = select(epListen+1, &frds, &fwds, NULL, &tv);
if(selgot > 0)
{
break;
}
WARNING_MSG(fmt::format("Components::updateComponentInfos: couldn't connect to:{}\n",
info->pIntAddr->c_str()));
return false;
}
}
epListen.setnodelay(true);
Network::Bundle* pBundle = Network::Bundle::createPoolObject();
// 由于COMMON_NETWORK_MESSAGE不包含client, 如果是bots, 我们需要单独处理
if(info->componentType != BOTS_TYPE)
{
COMMON_NETWORK_MESSAGE(info->componentType, (*pBundle), lookApp);
}
else
{
(*pBundle).newMessage(BotsInterface::lookApp);
}
epListen.send(pBundle->pCurrPacket()->data(), pBundle->pCurrPacket()->wpos());
Network::Bundle::reclaimPoolObject(pBundle);
fd_set fds;
struct timeval tv = { 0, 300000 }; // 100ms
FD_ZERO( &fds );
FD_SET((int)epListen, &fds);
int selgot = select(epListen+1, &fds, NULL, NULL, &tv);
if(selgot == 0)
{
// 超时, 可能对方繁忙
return true;
}
else if(selgot == -1)
{
return true;
}
else
{
COMPONENT_TYPE ctype;
COMPONENT_ID cid;
int8 istate = 0;
ArraySize entitySize = 0, cellSize = 0;
int32 clientsSize = 0, proxicesSize = 0;
uint32 telnet_port = 0;
Network::TCPPacket packet;
packet.resize(255);
int recvsize = sizeof(ctype) + sizeof(cid) + sizeof(istate);
if(info->componentType == CELLAPP_TYPE)
{
recvsize += sizeof(entitySize) + sizeof(cellSize) + sizeof(telnet_port);
}
if(info->componentType == BASEAPP_TYPE)
{
//.........这里部分代码省略.........