示例#1
0
Connection::Connection( Servent* parent )
    : QObject()
    , m_sock( 0 )
    , m_peerport( 0 )
    , m_servent( parent )
    , m_ready( false )
    , m_onceonly( true )
    , m_do_shutdown( false )
    , m_actually_shutting_down( false )
    , m_peer_disconnected( false )
    , m_tx_bytes( 0 )
    , m_tx_bytes_requested( 0 )
    , m_rx_bytes( 0 )
    , m_id( "Connection()" )
    , m_statstimer( 0 )
    , m_stats_tx_bytes_per_sec( 0 )
    , m_stats_rx_bytes_per_sec( 0 )
    , m_rx_bytes_last( 0 )
    , m_tx_bytes_last( 0 )
{
    moveToThread( m_servent->thread() );
    qDebug() << "CTOR Connection (super)" << thread();

    connect( &m_msgprocessor_out, SIGNAL( ready( msg_ptr ) ),
             SLOT( sendMsg_now( msg_ptr ) ), Qt::QueuedConnection );

    connect( &m_msgprocessor_in,  SIGNAL( ready( msg_ptr ) ),
             SLOT( handleMsg( msg_ptr ) ), Qt::QueuedConnection );

    connect( &m_msgprocessor_in, SIGNAL( empty() ),
             SLOT( handleIncomingQueueEmpty() ), Qt::QueuedConnection );
}
示例#2
0
Connection::Connection( Servent* parent )
    : QObject()
    , d_ptr( new ConnectionPrivate( this, parent ) )
{
    moveToThread( parent->thread() );
    tDebug( LOGVERBOSE ) << "CTOR Connection (super)" << thread();

    connect( &d_func()->msgprocessor_out, SIGNAL( ready( msg_ptr ) ),
             SLOT( sendMsg_now( msg_ptr ) ), Qt::QueuedConnection );

    connect( &d_func()->msgprocessor_in,  SIGNAL( ready( msg_ptr ) ),
             SLOT( handleMsg( msg_ptr ) ), Qt::QueuedConnection );

    connect( &d_func()->msgprocessor_in, SIGNAL( empty() ),
             SLOT( handleIncomingQueueEmpty() ), Qt::QueuedConnection );
}
示例#3
0
void
Connection::socketDisconnected()
{
    tDebug() << "SOCKET DISCONNECTED" << this->name() << id()
             << "shutdown will happen after incoming queue empties."
             << "bytesavail:" << m_sock->bytesAvailable()
             << "bytesRecvd" << bytesReceived();

    m_peer_disconnected = true;
    emit socketClosed();

    if( m_msgprocessor_in.length() == 0 && m_sock->bytesAvailable() == 0 )
    {
        handleIncomingQueueEmpty();
        actualShutdown();
    }
}
示例#4
0
void
Connection::socketDisconnected()
{
    Q_D( Connection );

    qint64 bytesAvailable = 0;
    if ( !d->sock.isNull() )
    {
        bytesAvailable = d->sock->bytesAvailable();
    }
    tDebug( LOGVERBOSE ) << "SOCKET DISCONNECTED" << this->name() << id()
                         << "shutdown will happen after incoming queue empties."
                         << "bytesavail:" << bytesAvailable
                         << "bytesRecvd" << bytesReceived();

    d->peer_disconnected = true;
    emit socketClosed();

    if ( d->msgprocessor_in.length() == 0 && bytesAvailable == 0 )
    {
        handleIncomingQueueEmpty();
        actualShutdown();
    }
}