本文整理汇总了C++中network::Bundle::newMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ Bundle::newMessage方法的具体用法?C++ Bundle::newMessage怎么用?C++ Bundle::newMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network::Bundle
的用法示例。
在下文中一共展示了Bundle::newMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newMail
//-------------------------------------------------------------------------------------
void EntityMailboxAbstract::newMail(Network::Bundle& bundle)
{
// If it is a server-side mailbox
if(g_componentType != CLIENT_TYPE && g_componentType != BOTS_TYPE)
{
// If the ID is 0, then this is a client-side component, otherwise the server-side.
if(componentID_ == 0)
{
bundle.newMessage(ClientInterface::onRemoteMethodCall);
}
else
{
Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(componentID_);
if(cinfos != NULL)
{
// Post a component found in the past, if the mailbox needs to transit such as e.base.cell, by baseapp transferred cellapp
if(cinfos->componentType == BASEAPP_TYPE)
{
bundle.newMessage(BaseappInterface::onEntityMail);
}
else
{
bundle.newMessage(CellappInterface::onEntityMail);
}
}
else
{
ERROR_MSG(fmt::format("EntityMailboxAbstract::newMail: not found component({}), entityID({})!\n",
componentID_, id_));
}
}
bundle << id_;
// If the package is sent to the client is not necessary to attach such a type
if(componentID_ > 0)
bundle << type_;
}
else
{
// If the mailbox is on the client calls the server-side method calls the cell or base
switch(type_)
{
case MAILBOX_TYPE_BASE:
bundle.newMessage(BaseappInterface::onRemoteMethodCall);
break;
case MAILBOX_TYPE_CELL:
bundle.newMessage(BaseappInterface::onRemoteCallCellMethodFromClient);
break;
default:
KBE_ASSERT(false && "no support!\n");
break;
};
bundle << id_;
}
}
示例2: newMail
//-------------------------------------------------------------------------------------
void EntityMailboxAbstract::newMail(Network::Bundle& bundle)
{
// 如果是server端的mailbox
if(g_componentType != CLIENT_TYPE && g_componentType != BOTS_TYPE)
{
// 如果ID为0,则这是一个客户端组件,否则为服务端。
if(componentID_ == 0)
{
bundle.newMessage(ClientInterface::onRemoteMethodCall);
}
else
{
Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(componentID_);
if(cinfos != NULL)
{
// 找到对应的组件投递过去, 如果这个mailbox还需要中转比如 e.base.cell , 则由baseapp转往cellapp
if(cinfos->componentType == BASEAPP_TYPE)
{
bundle.newMessage(BaseappInterface::onEntityMail);
}
else
{
bundle.newMessage(CellappInterface::onEntityMail);
}
}
else
{
ERROR_MSG(fmt::format("EntityMailboxAbstract::newMail: not found component({})!\n",
componentID_));
}
}
bundle << id_;
// 如果是发往客户端的包则无需附加这样一个类型
if(componentID_ > 0)
bundle << type_;
}
else
{
// 如果是客户端上的mailbox调用服务端方法只存在调用cell或者base
switch(type_)
{
case MAILBOX_TYPE_BASE:
bundle.newMessage(BaseappInterface::onRemoteMethodCall);
break;
case MAILBOX_TYPE_CELL:
bundle.newMessage(BaseappInterface::onRemoteCallCellMethodFromClient);
break;
default:
KBE_ASSERT(false && "no support!\n");
break;
};
bundle << id_;
}
}
示例3: onClientActiveTick
//-------------------------------------------------------------------------------------
void Loginapp::onClientActiveTick(Network::Channel* pChannel)
{
if(!pChannel->isExternal())
return;
onAppActiveTick(pChannel, CLIENT_TYPE, 0);
Network::Bundle* pBundle = Network::Bundle::createPoolObject();
pBundle->newMessage(ClientInterface::onAppActiveTickCB);
pChannel->send(pBundle);
}
示例4: onMessage
//-------------------------------------------------------------------------------------
void LogWatcher::onMessage(uint32 logtype, COMPONENT_TYPE componentType, COMPONENT_ID componentID, COMPONENT_ORDER componentOrder,
int64 tm, GAME_TIME kbetime, const std::string& str, const std::stringstream& sstr)
{
if(!VALID_COMPONENT(componentType) || componentBitmap_[componentType] == 0)
return;
if((logtypes_ & logtype) <= 0)
return;
if(appOrder_ > 0 && appOrder_ != componentOrder)
return;
Network::Channel* pChannel = Messagelog::getSingleton().networkInterface().findChannel(addr_);
if(pChannel == NULL)
return;
Network::Bundle bundle;
ConsoleInterface::ConsoleLogMessageHandler msgHandler;
bundle.newMessage(msgHandler);
bundle << sstr.str().c_str();
bundle.send(Messagelog::getSingleton().networkInterface(), pChannel);
}
示例5: proxy
//-------------------------------------------------------------------------------------
thread::TPTask::TPTaskState DataDownload::presentMainThread()
{
if(error_)
{
ERROR_MSG(fmt::format("DataDownload::presentMainThread: proxy({}), downloadID({}), type({}), thread error.\n",
entityID(), id(), type()));
return thread::TPTask::TPTASK_STATE_COMPLETED;
}
uint32 datasize = GAME_PACKET_MAX_SIZE_TCP - sizeof(int16) - sizeof(uint32);
if(remainSent_ > 0 && currSent_ < remainSent_)
{
Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
if(!sentStart_)
{
pBundle->newMessage(ClientInterface::onStreamDataStarted);
(*pBundle) << this->id();
(*pBundle) << totalBytes_;
(*pBundle) << descr_;
(*pBundle) << type();
sentStart_ = true;
if(!send(ClientInterface::onStreamDataStarted, pBundle))
{
DEBUG_MSG(fmt::format("DataDownload::presentMainThread: proxy({}), downloadID({}), type({}), thread exit.\n",
entityID(), id(), type()));
return thread::TPTask::TPTASK_STATE_COMPLETED;
}
return thread::TPTask::TPTASK_STATE_CONTINUE_MAINTHREAD;
}
pBundle->newMessage(ClientInterface::onStreamDataRecv);
(*pBundle) << id();
if(remainSent_ - currSent_ > datasize)
{
(*pBundle) << datasize;
(*pBundle).append(getOutStream() + currSent_, datasize);
currSent_ += datasize;
totalSentBytes_ += datasize;
if(!send(ClientInterface::onStreamDataRecv, pBundle))
{
DEBUG_MSG(fmt::format("DataDownload::presentMainThread: proxy({}), downloadID({}), type({}), thread exit.\n",
entityID(), id(), type()));
error_ = true;
return thread::TPTask::TPTASK_STATE_COMPLETED;
}
}
else
{
datasize = remainSent_ - currSent_;
(*pBundle) << datasize;
(*pBundle).append(getOutStream() + currSent_, datasize);
if(!send(ClientInterface::onStreamDataRecv, pBundle))
{
DEBUG_MSG(fmt::format("DataDownload::presentMainThread: proxy({}), downloadID({}), type({}), thread exit.\n",
entityID(), id(), type()));
error_ = true;
return thread::TPTask::TPTASK_STATE_COMPLETED;
}
totalSentBytes_ += datasize;
currSent_ = remainSent_;
}
}
if(totalSentBytes_ == totalBytes_)
{
DEBUG_MSG(fmt::format("DataDownload::presentMainThread: proxy({0}), downloadID({1}), type({6}), sentBytes={5},{2}/{3} ({4:.2f}%).\n",
entityID(), id(), totalSentBytes_, this->totalBytes(), 100.0f, datasize, type()));
pDataDownloads_->onDownloadCompleted(this);
Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
pBundle->newMessage(ClientInterface::onStreamDataCompleted);
(*pBundle) << this->id();
send(ClientInterface::onStreamDataCompleted, pBundle);
return thread::TPTask::TPTASK_STATE_COMPLETED;
}
DEBUG_MSG(fmt::format("DataDownload::presentMainThread: proxy({0}), downloadID({1}), type({6}), sentBytes={5},{2}/{3} ({4:.2f}%).\n",
entityID(), id(), totalSentBytes_, this->totalBytes(),
(((float)totalSentBytes_ / (float)this->totalBytes()) * 100.0f), datasize, type()));
if(currSent_ == remainSent_)
{
//.........这里部分代码省略.........