本文整理汇总了C++中network::Bundle::currMsgLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Bundle::currMsgLength方法的具体用法?C++ Bundle::currMsgLength怎么用?C++ Bundle::currMsgLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network::Bundle
的用法示例。
在下文中一共展示了Bundle::currMsgLength方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tp_call
//-------------------------------------------------------------------------------------
PyObject* BaseRemoteMethod::tp_call(PyObject* self, PyObject* args,
PyObject* kwds)
{
BaseRemoteMethod* rmethod = static_cast<BaseRemoteMethod*>(self);
MethodDescription* methodDescription = rmethod->getDescription();
EntityMailboxAbstract* mailbox = rmethod->getMailbox();
if(!mailbox->isClient())
{
return RemoteEntityMethod::tp_call(self, args, kwds);
}
Base* pEntity = Baseapp::getSingleton().findEntity(mailbox->id());
if(pEntity == NULL)
{
//WARNING_MSG(fmt::format("BaseRemoteMethod::callClientMethod: not found entity({}).\n",
// mailbox->id()));
return RemoteEntityMethod::tp_call(self, args, kwds);
}
// 如果是调用客户端方法, 我们记录事件并且记录带宽
if(methodDescription->checkArgs(args))
{
Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
mailbox->newMail((*pBundle));
MemoryStream* mstream = MemoryStream::ObjPool().createObject();
methodDescription->addToStream(mstream, args);
if(mstream->wpos() > 0)
(*pBundle).append(mstream->data(), mstream->wpos());
// 记录这个事件产生的数据量大小
g_privateClientEventHistoryStats.trackEvent(pEntity->scriptName(),
methodDescription->getName(),
pBundle->currMsgLength(),
"::");
static_cast<Proxy*>(pEntity)->sendToClient(ClientInterface::onRemoteMethodCall, pBundle);
//Network::Bundle::ObjPool().reclaimObject(pBundle);
MemoryStream::ObjPool().reclaimObject(mstream);
}
S_Return;
}
示例2: onDefDataChanged
//-------------------------------------------------------------------------------------
void Base::onDefDataChanged(const PropertyDescription* propertyDescription,
PyObject* pyData)
{
if(initing())
return;
if(propertyDescription->isPersistent())
setDirty();
uint32 flags = propertyDescription->getFlags();
if((flags & ED_FLAG_BASE_AND_CLIENT) <= 0 || clientMailbox_ == NULL)
return;
// 创建一个需要广播的模板流
MemoryStream* mstream = MemoryStream::createPoolObject();
propertyDescription->getDataType()->addToStream(mstream, pyData);
Network::Bundle* pBundle = Network::Bundle::createPoolObject();
(*pBundle).newMessage(ClientInterface::onUpdatePropertys);
(*pBundle) << id();
if(pScriptModule_->usePropertyDescrAlias())
(*pBundle) << propertyDescription->aliasIDAsUint8();
else
(*pBundle) << propertyDescription->getUType();
pBundle->append(*mstream);
g_privateClientEventHistoryStats.trackEvent(scriptName(),
propertyDescription->getName(),
pBundle->currMsgLength());
// 按照当前的设计来说,有clientMailbox_必定是proxy
// 至于为何跑到base里来和python本身是C语言实现有关
static_cast<Proxy*>(this)->sendToClient(ClientInterface::onUpdatePropertys, pBundle);
MemoryStream::reclaimPoolObject(mstream);
}
示例3: tp_call
//-------------------------------------------------------------------------------------
PyObject* EntityRemoteMethod::tp_call(PyObject* self, PyObject* args,
PyObject* kwds)
{
EntityRemoteMethod* rmethod = static_cast<EntityRemoteMethod*>(self);
MethodDescription* methodDescription = rmethod->getDescription();
EntityMailboxAbstract* mailbox = rmethod->getMailbox();
if(!mailbox->isClient())
{
return RemoteEntityMethod::tp_call(self, args, kwds);
}
Entity* pEntity = Cellapp::getSingleton().findEntity(mailbox->id());
if(pEntity == NULL || pEntity->pWitness() == NULL)
{
//WARNING_MSG(fmt::format("EntityRemoteMethod::callClientMethod: not found entity({}).\n",
// mailbox->id()));
return RemoteEntityMethod::tp_call(self, args, kwds);
}
Network::Channel* pChannel = pEntity->pWitness()->pChannel();
if(!pChannel)
{
PyErr_Format(PyExc_AssertionError, "%s:EntityRemoteMethod(%s)::tp_call: no client, srcEntityID(%d).\n",
pEntity->scriptName(), methodDescription->getName(), pEntity->id());
PyErr_PrintEx(0);
return RemoteEntityMethod::tp_call(self, args, kwds);
}
// 如果是调用客户端方法, 我们记录事件并且记录带宽
if(methodDescription->checkArgs(args))
{
Network::Bundle* pBundle = pChannel->createSendBundle();
mailbox->newMail((*pBundle));
MemoryStream* mstream = MemoryStream::createPoolObject();
methodDescription->addToStream(mstream, args);
if(mstream->wpos() > 0)
(*pBundle).append(mstream->data(), (int)mstream->wpos());
if(Network::g_trace_packet > 0)
{
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger("packetlogs");
DEBUG_MSG(fmt::format("EntityRemoteMethod::tp_call: pushUpdateData: ClientInterface::onRemoteMethodCall({}::{})\n",
pEntity->scriptName(), methodDescription->getName()));
switch(Network::g_trace_packet)
{
case 1:
mstream->hexlike();
break;
case 2:
mstream->textlike();
break;
default:
mstream->print_storage();
break;
};
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger(COMPONENT_NAME_EX(g_componentType));
}
// 记录这个事件产生的数据量大小
g_privateClientEventHistoryStats.trackEvent(pEntity->scriptName(),
methodDescription->getName(),
pBundle->currMsgLength(),
"::");
pEntity->pWitness()->sendToClient(ClientInterface::onRemoteMethodCall, pBundle);
MemoryStream::reclaimPoolObject(mstream);
}
S_Return;
}
示例4: callmethod
//.........这里部分代码省略.........
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity(%s): no client, srcEntityID(%d).\n",
srcEntity->scriptName(), methodDescription_->getName(), srcEntity->id());
PyErr_PrintEx(0);
return 0;
}
Network::Channel* pChannel = srcEntity->pWitness()->pChannel();
if(!pChannel)
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity(%s): no client, srcEntityID(%d).\n",
srcEntity->scriptName(), methodDescription_->getName(), srcEntity->id());
PyErr_PrintEx(0);
return 0;
}
EntityRef* pEntityRef = srcEntity->pWitness()->getAOIEntityRef(clientEntityID_);
Entity* e = (pEntityRef && ((pEntityRef->flags() & (ENTITYREF_FLAG_ENTER_CLIENT_PENDING | ENTITYREF_FLAG_LEAVE_CLIENT_PENDING)) <= 0))
? pEntityRef->pEntity() : NULL;
if(e == NULL)
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity(%s): not found entity(%d), srcEntityID(%d).\n",
srcEntity->scriptName(), methodDescription_->getName(), clientEntityID_, srcEntity->id());
PyErr_PrintEx(0);
return 0;
}
MethodDescription* methodDescription = getDescription();
if(methodDescription->checkArgs(args))
{
MemoryStream* mstream = MemoryStream::createPoolObject();
methodDescription->addToStream(mstream, args);
Network::Bundle* pSendBundle = pChannel->createSendBundle();
NETWORK_ENTITY_MESSAGE_FORWARD_CLIENT_START(srcEntity->id(), (*pSendBundle));
int ialiasID = -1;
const Network::MessageHandler& msgHandler =
srcEntity->pWitness()->getAOIEntityMessageHandler(ClientInterface::onRemoteMethodCall,
ClientInterface::onRemoteMethodCallOptimized, clientEntityID_, ialiasID);
ENTITY_MESSAGE_FORWARD_CLIENT_START(pSendBundle, msgHandler, aOIEntityMessage);
if(ialiasID != -1)
{
KBE_ASSERT(msgHandler.msgID == ClientInterface::onRemoteMethodCallOptimized.msgID);
(*pSendBundle) << (uint8)ialiasID;
}
else
{
KBE_ASSERT(msgHandler.msgID == ClientInterface::onRemoteMethodCall.msgID);
(*pSendBundle) << clientEntityID_;
}
if(mstream->wpos() > 0)
(*pSendBundle).append(mstream->data(), (int)mstream->wpos());
if(Network::g_trace_packet > 0)
{
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger("packetlogs");
DEBUG_MSG(fmt::format("ClientEntityMethod::callmethod: pushUpdateData: ClientInterface::onRemoteOtherEntityMethodCall({}::{})\n",
srcEntity->scriptName(), methodDescription->getName()));
switch(Network::g_trace_packet)
{
case 1:
mstream->hexlike();
break;
case 2:
mstream->textlike();
break;
default:
mstream->print_storage();
break;
};
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger(COMPONENT_NAME_EX(g_componentType));
}
ENTITY_MESSAGE_FORWARD_CLIENT_END(pSendBundle, msgHandler, aOIEntityMessage);
// 记录这个事件产生的数据量大小
g_publicClientEventHistoryStats.trackEvent(srcEntity->scriptName(),
(std::string(e->scriptName()) + "." + methodDescription->getName()),
pSendBundle->currMsgLength(),
"::");
srcEntity->pWitness()->sendToClient(ClientInterface::onRemoteMethodCallOptimized, pSendBundle);
MemoryStream::reclaimPoolObject(mstream);
}
S_Return;
}
示例5: callmethod
//-------------------------------------------------------------------------------------
PyObject* RealEntityMethod::callmethod(PyObject* args, PyObject* kwds)
{
MethodDescription* methodDescription = getDescription();
if(methodDescription->checkArgs(args))
{
MemoryStream* mstream = MemoryStream::ObjPool().createObject();
methodDescription->addToStream(mstream, args);
Network::Bundle* pForwardBundle = Network::Bundle::ObjPool().createObject();
(*pForwardBundle).newMessage(CellappInterface::onRemoteRealMethodCall);
(*pForwardBundle) << ghostEntityID_;
if(mstream->wpos() > 0)
(*pForwardBundle).append(mstream->data(), mstream->wpos());
if(Network::g_trace_packet > 0)
{
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger("packetlogs");
DEBUG_MSG(fmt::format("RealEntityMethod::callmethod: pushUpdateData: CellappInterface::onRemoteRealMethodCall({2}({0})::{1})\n",
ghostEntityID_, methodDescription->getName(), scriptName_));
switch(Network::g_trace_packet)
{
case 1:
mstream->hexlike();
break;
case 2:
mstream->textlike();
break;
default:
mstream->print_storage();
break;
};
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger(COMPONENT_NAME_EX(g_componentType));
}
// 记录这个事件产生的数据量大小
g_publicCellEventHistoryStats.trackEvent(scriptName_,
methodDescription->getName(),
pForwardBundle->currMsgLength(),
"::");
MemoryStream::ObjPool().reclaimObject(mstream);
GhostManager* gm = Cellapp::getSingleton().pGhostManager();
if(gm)
{
gm->pushMessage(realCell_, pForwardBundle);
}
else
{
Network::Bundle::ObjPool().reclaimObject(pForwardBundle);
}
}
S_Return;
}
示例6: callmethod
//-------------------------------------------------------------------------------------
PyObject* ClientEntityMethod::callmethod(PyObject* args, PyObject* kwds)
{
Entity* srcEntity = Cellapp::getSingleton().findEntity(srcEntityID_);
if(srcEntity == NULL)
{
PyErr_Format(PyExc_AssertionError, "Entity::clientEntity(%s): srcEntityID(%d) not found!\n",
methodDescription_->getName(), srcEntityID_);
PyErr_PrintEx(0);
return 0;
}
if(srcEntity->isDestroyed())
{
PyErr_Format(PyExc_AssertionError, "Entity::clientEntity(%s): srcEntityID(%d) is destroyed!\n",
methodDescription_->getName(), srcEntityID_);
PyErr_PrintEx(0);
return 0;
}
if(srcEntity->pWitness() == NULL)
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity(%s): no client, srcEntityID(%d).\n",
srcEntity->scriptName(), methodDescription_->getName(), srcEntity->id());
PyErr_PrintEx(0);
return 0;
}
EntityRef::AOI_ENTITIES::iterator iter = srcEntity->pWitness()->aoiEntities().begin();
Entity* e = NULL;
for(; iter != srcEntity->pWitness()->aoiEntities().end(); ++iter)
{
if((*iter)->id() == clientEntityID_ && ((*iter)->flags() &
(ENTITYREF_FLAG_ENTER_CLIENT_PENDING | ENTITYREF_FLAG_LEAVE_CLIENT_PENDING)) <= 0)
{
e = (*iter)->pEntity();
break;
}
}
if(e == NULL)
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity(%s): not found entity(%d), srcEntityID(%d).\n",
srcEntity->scriptName(), methodDescription_->getName(), clientEntityID_, srcEntity->id());
PyErr_PrintEx(0);
return 0;
}
MethodDescription* methodDescription = getDescription();
if(methodDescription->checkArgs(args))
{
MemoryStream* mstream = MemoryStream::ObjPool().createObject();
methodDescription->addToStream(mstream, args);
Network::Bundle* pForwardBundle = Network::Bundle::ObjPool().createObject();
Network::Bundle* pSendBundle = Network::Bundle::ObjPool().createObject();
srcEntity->pWitness()->addSmartAOIEntityMessageToBundle(pForwardBundle, ClientInterface::onRemoteMethodCall,
ClientInterface::onRemoteMethodCallOptimized, clientEntityID_);
if(mstream->wpos() > 0)
(*pForwardBundle).append(mstream->data(), (int)mstream->wpos());
if(Network::g_trace_packet > 0)
{
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger("packetlogs");
DEBUG_MSG(fmt::format("ClientEntityMethod::callmethod: pushUpdateData: ClientInterface::onRemoteOtherEntityMethodCall({}::{})\n",
srcEntity->scriptName(), methodDescription->getName()));
switch(Network::g_trace_packet)
{
case 1:
mstream->hexlike();
break;
case 2:
mstream->textlike();
break;
default:
mstream->print_storage();
break;
};
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger(COMPONENT_NAME_EX(g_componentType));
}
NETWORK_ENTITY_MESSAGE_FORWARD_CLIENT(srcEntity->id(), (*pSendBundle), (*pForwardBundle));
srcEntity->pWitness()->sendToClient(ClientInterface::onRemoteMethodCallOptimized, pSendBundle);
// 记录这个事件产生的数据量大小
g_publicClientEventHistoryStats.trackEvent(srcEntity->scriptName(),
(std::string(e->scriptName()) + "." + methodDescription->getName()),
pForwardBundle->currMsgLength(),
//.........这里部分代码省略.........
示例7: callmethod
//-------------------------------------------------------------------------------------
PyObject* ClientsRemoteEntityMethod::callmethod(PyObject* args, PyObject* kwds)
{
// 获取entityAOI范围内其他entity
// 向这些entity的client推送这个方法的调用
MethodDescription* methodDescription = getDescription();
Entity* pEntity = Cellapp::getSingleton().findEntity(id_);
if(pEntity == NULL || /*pEntity->pWitness() == NULL ||*/
pEntity->isDestroyed() /*|| pEntity->clientMailbox() == NULL*/)
{
//WARNING_MSG(fmt::format("EntityRemoteMethod::callClientMethod: not found entity({}).\n",
// mailbox->id()));
S_Return;
}
const std::list<ENTITY_ID>& entities = pEntity->witnesses();
if(otherClients_)
{
if(pEntity->witnessesSize() == 0)
S_Return;
}
// 先发给自己
if(methodDescription->checkArgs(args))
{
MemoryStream* mstream = MemoryStream::ObjPool().createObject();
methodDescription->addToStream(mstream, args);
if((!otherClients_ && (pEntity->pWitness() || (pEntity->clientMailbox()))))
{
Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
pEntity->clientMailbox()->newMail((*pBundle));
if(mstream->wpos() > 0)
(*pBundle).append(mstream->data(), mstream->wpos());
if(Network::g_trace_packet > 0)
{
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger("packetlogs");
DEBUG_MSG(fmt::format("ClientsRemoteEntityMethod::callmethod: pushUpdateData: ClientInterface::onRemoteMethodCall({}::{})\n",
pEntity->scriptName(), methodDescription->getName()));
switch(Network::g_trace_packet)
{
case 1:
mstream->hexlike();
break;
case 2:
mstream->textlike();
break;
default:
mstream->print_storage();
break;
};
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger(COMPONENT_NAME_EX(g_componentType));
}
//mailbox->postMail((*pBundle));
pEntity->pWitness()->sendToClient(ClientInterface::onRemoteMethodCall, pBundle);
// 记录这个事件产生的数据量大小
g_publicClientEventHistoryStats.trackEvent(pEntity->scriptName(),
methodDescription->getName(),
pBundle->currMsgLength(),
"::");
}
// 广播给其他人
std::list<ENTITY_ID>::const_iterator iter = entities.begin();
for(; iter != entities.end(); ++iter)
{
Entity* pAoiEntity = Cellapp::getSingleton().findEntity((*iter));
if(pAoiEntity == NULL || pAoiEntity->pWitness() == NULL || pAoiEntity->isDestroyed())
continue;
EntityMailbox* mailbox = pAoiEntity->clientMailbox();
if(mailbox == NULL)
continue;
Network::Channel* pChannel = mailbox->getChannel();
if(pChannel == NULL)
continue;
if(!pAoiEntity->pWitness()->entityInAOI(pEntity->id()))
continue;
Network::Bundle* pSendBundle = Network::Bundle::ObjPool().createObject();
Network::Bundle* pForwardBundle = Network::Bundle::ObjPool().createObject();
pAoiEntity->pWitness()->addSmartAOIEntityMessageToBundle(pForwardBundle, ClientInterface::onRemoteMethodCall,
ClientInterface::onRemoteMethodCallOptimized, pEntity->id());
if(mstream->wpos() > 0)
//.........这里部分代码省略.........