本文整理汇总了C++中YMSGTransfer::packetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ YMSGTransfer::packetLength方法的具体用法?C++ YMSGTransfer::packetLength怎么用?C++ YMSGTransfer::packetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YMSGTransfer
的用法示例。
在下文中一共展示了YMSGTransfer::packetLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wireToTransfer
int CoreProtocol::wireToTransfer( const QByteArray& wire )
{
kDebug(YAHOO_RAW_DEBUG) ;
// processing incoming data and reassembling it into transfers
// may be an event or a response
uint bytesParsed = 0;
if ( wire.size() < 20 ) // minimal value of a YMSG header
{
m_state = NeedMore;
return bytesParsed;
}
QByteArray tempWire = wire;
QDataStream din( &tempWire, QIODevice::ReadOnly );
// look at first four bytes and decide what to do with the chunk
if ( okToProceed( din ) )
{
if ( (wire[0] == 'Y') && (wire[1] == 'M') && (wire[2] == 'S') && (wire[3] == 'G'))
{
// kDebug(YAHOO_RAW_DEBUG) << " - looks like a valid YMSG packet";
YMSGTransfer *t = static_cast<YMSGTransfer *>(m_YMSGProtocol->parse( wire, bytesParsed ));
// kDebug(YAHOO_RAW_DEBUG) << " - YMSG Protocol parsed " << bytesParsed << " bytes";
if ( t )
{
if( wire.size() < t->packetLength() )
{
m_state = NeedMore;
delete t;
return 0;
}
m_inTransfer = t;
// kDebug(YAHOO_RAW_DEBUG) << " - got a valid packet ";
m_state = Available;
emit incomingData();
}
else
bytesParsed = 0;
}
else
{
kDebug(YAHOO_RAW_DEBUG) << " - not a valid YMSG packet. Trying to recover.";
QTextStream s( wire, QIODevice::ReadOnly );
QString remaining = s.readAll();
int pos = remaining.indexOf( "YMSG", bytesParsed );
if( pos >= 0 )
{
kDebug(YAHOO_RAW_DEBUG) << "Recover successful.";
bytesParsed += pos;
}
else
{
kDebug(YAHOO_RAW_DEBUG) << "Recover failed. Dump it!";
bytesParsed = wire.size();
}
}
}
return bytesParsed;
}