本文整理汇总了C++中Stream::GetContext方法的典型用法代码示例。如果您正苦于以下问题:C++ Stream::GetContext方法的具体用法?C++ Stream::GetContext怎么用?C++ Stream::GetContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::GetContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
template <typename Stream> bool ConnectionPacket::Serialize( Stream & stream )
{
ConnectionContext * context = (ConnectionContext*) stream.GetContext();
assert( context );
assert( context->magic == ConnectionContextMagic );
assert( context->messageFactory );
assert( context->connectionConfig );
// ack system
bool perfect_acks = Stream::IsWriting ? ( ack_bits == 0xFFFFFFFF ) : 0;
serialize_bool( stream, perfect_acks );
if ( !perfect_acks )
serialize_bits( stream, ack_bits, 32 );
else
ack_bits = 0xFFFFFFFF;
serialize_bits( stream, sequence, 16 );
serialize_ack_relative( stream, sequence, ack );
// channel entries
const int numChannels = context->connectionConfig->numChannels;
serialize_int( stream, numChannelEntries, 0, context->connectionConfig->numChannels );
#if YOJIMBO_VALIDATE_PACKET_BUDGET
assert( stream.GetBitsProcessed() <= ConservativeConnectionPacketHeaderEstimate );
#endif // #if YOJIMBO_VALIDATE_PACKET_BUDGET
if ( numChannelEntries > 0 )
{
if ( Stream::IsReading )
{
if ( !AllocateChannelData( *context->messageFactory, numChannelEntries ) )
return false;
}
for ( int i = 0; i < numChannelEntries; ++i )
{
if ( !channelEntry[i].SerializeInternal( stream, *m_messageFactory, context->connectionConfig->channelConfig, numChannels ) )
return false;
}
}
return true;
}