本文整理汇总了C++中msg_ptr::payload方法的典型用法代码示例。如果您正苦于以下问题:C++ msg_ptr::payload方法的具体用法?C++ msg_ptr::payload怎么用?C++ msg_ptr::payload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msg_ptr
的用法示例。
在下文中一共展示了msg_ptr::payload方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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() );
}
示例2: qDebug
void
MsgProcessor::append( msg_ptr msg )
{
if( QThread::currentThread() != thread() )
{
qDebug() << "reinvoking msgprocessor::append in correct thread, ie not" << QThread::currentThread();
QMetaObject::invokeMethod( this, "append", Qt::QueuedConnection, Q_ARG(msg_ptr, msg) );
return;
}
m_msgs.append( msg );
m_msg_ready.insert( msg.data(), false );
m_totmsgsize += msg->payload().length();
if( m_mode & NOTHING )
{
//qDebug() << "MsgProcessor::NOTHING";
handleProcessedMsg( msg );
return;
}
QFuture<msg_ptr> fut = QtConcurrent::run(&MsgProcessor::process, msg, m_mode, m_threshold);
QFutureWatcher<msg_ptr> * watcher = new QFutureWatcher<msg_ptr>;
connect( watcher, SIGNAL( finished() ),
this, SLOT( processed() ),
Qt::QueuedConnection );
watcher->setFuture( fut );
}
示例3: if
void
StreamConnection::handleMsg( msg_ptr msg )
{
Q_ASSERT( msg->is( Msg::RAW ) );
if ( msg->payload().startsWith( "block" ) )
{
int block = QString( msg->payload() ).mid( 5 ).toInt();
m_readdev->seek( block * BufferIODevice::blockSize() );
qDebug() << "Seeked to block:" << block;
QByteArray sm;
sm.append( QString( "doneblock%1" ).arg( block ) );
sendMsg( Msg::factory( sm, Msg::RAW | Msg::FRAGMENT ) );
QTimer::singleShot( 0, this, SLOT( sendSome() ) );
}
else if ( msg->payload().startsWith( "doneblock" ) )
{
int block = QString( msg->payload() ).mid( 9 ).toInt();
( (BufferIODevice*)m_iodev.data() )->seeked( block );
m_curBlock = block;
qDebug() << "Next block is now:" << block;
}
else if ( msg->payload().startsWith( "data" ) )
{
m_badded += msg->payload().length() - 4;
( (BufferIODevice*)m_iodev.data() )->addData( m_curBlock++, msg->payload().mid( 4 ) );
}
//qDebug() << Q_FUNC_INFO << "flags" << (int) msg->flags()
// << "payload len" << msg->payload().length()
// << "written to device so far: " << m_badded;
if ( m_iodev && ( (BufferIODevice*)m_iodev.data() )->nextEmptyBlock() < 0 )
{
m_allok = true;
// tell our iodev there is no more data to read, no args meaning a success:
( (BufferIODevice*)m_iodev.data() )->inputComplete();
shutdown();
}
}
示例4: changeState
void
DBSyncConnection::handleMsg( msg_ptr msg )
{
Q_ASSERT( !msg->is( Msg::COMPRESSED ) );
if ( m_state == FETCHING )
changeState( PARSING );
// "everything is synced" indicated by non-json msg containing "ok":
if ( !msg->is( Msg::JSON ) &&
msg->is( Msg::DBOP ) &&
msg->payload() == "ok" )
{
changeState( SYNCED );
// calc the collection stats, to updates the "X tracks" in the sidebar etc
// this is done automatically if you run a dbcmd to add files.
DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( m_source );
connect( cmd, SIGNAL( done( const QVariantMap & ) ),
m_source.data(), SLOT( setStats( const QVariantMap& ) ), Qt::QueuedConnection );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
return;
}