本文整理汇总了C++中MessageBuffer::getDataSize方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageBuffer::getDataSize方法的具体用法?C++ MessageBuffer::getDataSize怎么用?C++ MessageBuffer::getDataSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageBuffer
的用法示例。
在下文中一共展示了MessageBuffer::getDataSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendClientConnect
void CheriaServer::sendClientConnect(ProtocolServer::ClientState* sourceCs,ProtocolServer::ClientState* destCs,Comm::NetPipe& pipe)
{
/* Get handles on the Cheria state objects: */
ClientState* mySourceCs=dynamic_cast<ClientState*>(sourceCs);
ClientState* myDestCs=dynamic_cast<ClientState*>(destCs);
if(mySourceCs==0||myDestCs==0)
Misc::throwStdErr("CheriaServer::sendClientConnect: Client state object has mismatching type");
#if DEBUGGING
std::cout<<"CheriaServer::sendClientConnect..."<<std::flush;
#endif
/* Create a temporary message buffer with the same endianness as the pipe's write end: */
MessageBuffer buffer;
buffer.setSwapOnWrite(pipe.mustSwapOnWrite());
/*********************************************************************
Assemble the update message in the temporary buffer:
*********************************************************************/
/* Send creation messages for the source client's devices to the destination client: */
for(ClientDeviceMap::Iterator cdIt=mySourceCs->clientDevices.begin();!cdIt.isFinished();++cdIt)
{
writeMessage(CREATE_DEVICE,buffer);
buffer.write<Card>(cdIt->getSource());
cdIt->getDest()->writeLayout(buffer);
}
/* Send creation messages for the source client's tools to the destination client: */
for(ClientToolMap::Iterator ctIt=mySourceCs->clientTools.begin();!ctIt.isFinished();++ctIt)
{
writeMessage(CREATE_TOOL,buffer);
buffer.write<Card>(ctIt->getSource());
ctIt->getDest()->write(buffer);
}
/* Send the current states of the source client's devices: */
writeMessage(DEVICE_STATES,buffer);
for(ClientDeviceMap::Iterator cdIt=mySourceCs->clientDevices.begin();!cdIt.isFinished();++cdIt)
{
/* Send a device state message: */
buffer.write<Card>(cdIt->getSource());
cdIt->getDest()->write(DeviceState::FULL_UPDATE,buffer);
}
buffer.write<Card>(0);
/*********************************************************************
Send the assembled message to the client in one go:
*********************************************************************/
#if DEBUGGING
std::cout<<" message size "<<buffer.getDataSize()<<std::endl;
#endif
/* Write the message's total size first: */
pipe.write<Card>(buffer.getDataSize());
/* Write the message itself: */
buffer.writeToSink(pipe);
}