本文整理汇总了C++中msg_ptr::length方法的典型用法代码示例。如果您正苦于以下问题:C++ msg_ptr::length方法的具体用法?C++ msg_ptr::length怎么用?C++ msg_ptr::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msg_ptr
的用法示例。
在下文中一共展示了msg_ptr::length方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qDebug
void
Connection::sendMsg( msg_ptr msg )
{
if( m_do_shutdown )
{
qDebug() << Q_FUNC_INFO << "SHUTTING DOWN, NOT SENDING msg flags:"
<< (int)msg->flags() << "length:" << msg->length() << id();
return;
}
m_tx_bytes_requested += msg->length() + Msg::headerSize();
m_msgprocessor_out.append( msg );
}
示例2: tDebug
void
Connection::sendMsg( msg_ptr msg )
{
if ( d_func()->do_shutdown )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "SHUTTING DOWN, NOT SENDING msg flags:"
<< (int)msg->flags() << "length:" << msg->length() << id();
return;
}
d_func()->tx_bytes_requested += msg->length() + Msg::headerSize();
d_func()->msgprocessor_out.append( msg );
}
示例3: if
void
ControlConnection::handleMsg( msg_ptr msg )
{
if ( msg->is( Msg::PING ) )
{
// qDebug() << "Received Connection PING, nice." << m_pingtimer_mark.elapsed();
m_pingtimer_mark.restart();
return;
}
// if small and not compresed, print it out for debug
if ( msg->length() < 1024 && !msg->is( Msg::COMPRESSED ) )
{
qDebug() << id() << "got msg:" << QString::fromLatin1( msg->payload() );
}
// All control connection msgs are JSON
if ( !msg->is( Msg::JSON ) )
{
Q_ASSERT( msg->is( Msg::JSON ) );
markAsFailed();
return;
}
QVariantMap m = msg->json().toMap();
if ( !m.isEmpty() )
{
if ( m.value( "conntype" ).toString() == "request-offer" )
{
QString theirkey = m["key"].toString();
QString ourkey = m["offer"].toString();
QString theirdbid = m["controlid"].toString();
servent()->reverseOfferRequest( this, theirdbid, ourkey, theirkey );
}
else if ( m.value( "method" ).toString() == "dbsync-offer" )
{
m_dbconnkey = m.value( "key" ).toString() ;
setupDbSyncConnection();
}
else if ( m.value( "method" ) == "protovercheckfail" )
{
qDebug() << "*** Remote peer protocol version mismatch, connection closed";
shutdown( true );
return;
}
else
{
tDebug() << id() << "Unhandled msg:" << QString::fromLatin1( msg->payload() );
}
return;
}
tDebug() << id() << "Invalid msg:" << QString::fromLatin1( msg->payload() );
}
示例4: qDebug
/// This method is run by QtConcurrent:
msg_ptr
MsgProcessor::process( msg_ptr msg, quint32 mode, quint32 threshold )
{
// uncompress if needed
if( (mode & UNCOMPRESS_ALL) && msg->is( Msg::COMPRESSED ) )
{
qDebug() << "MsgProcessor::UNCOMPRESSING";
msg->m_payload = qUncompress( msg->payload() );
msg->m_length = msg->m_payload.length();
msg->m_flags ^= Msg::COMPRESSED;
}
// parse json payload into qvariant if needed
if( (mode & PARSE_JSON) &&
msg->is( Msg::JSON ) &&
msg->m_json_parsed == false )
{
qDebug() << "MsgProcessor::PARSING JSON";
bool ok;
QJson::Parser parser;
msg->m_json = parser.parse( msg->payload(), &ok );
msg->m_json_parsed = true;
}
// compress if needed
if( (mode & COMPRESS_IF_LARGE) &&
!msg->is( Msg::COMPRESSED )
&& msg->length() > threshold )
{
qDebug() << "MsgProcessor::COMPRESSING";
msg->m_payload = qCompress( msg->payload(), 9 );
msg->m_length = msg->m_payload.length();
msg->m_flags |= Msg::COMPRESSED;
}
return msg;
}