pelican/output/src/TCPConnectionManager.cpp
/**
 * @details
 * Send data to connected clients
 */
@details
Send data to connected clients
@details Send data to connected clients
void TCPConnectionManager::send(const QString& streamName, const DataBlob* blob)
{
    QMutexLocker sendlocker(&_sendMutex);
    if (_clients.contains(streamName))
    {
        clients_t clientListCopy;
        {
            QMutexLocker locker(&_mutex);
            clientListCopy = _clients[streamName];
        }
        for(int i = 0; i < clientListCopy.size(); ++i )
        {
            QTcpSocket* client =  clientListCopy[i];
            try {
                Q_ASSERT( client->state() == QAbstractSocket::ConnectedState );
                _protocol->send(*client, streamName, *blob);
                client->flush();
            }
            catch ( ... )
            {
                std::cerr <<  "TCPConnectionManager: failed to send data to client" << std::endl;
                _killClient(client);
            }
        }
    }
    emit sent(blob); 
    if (!_seenTypes.contains(streamName))
    {
        _seenTypes.insert(streamName);
        _sendNewDataTypes();
    }
}
void TCPConnectionManager :: send ( const QString & streamName , const DataBlob * blob ) { QMutexLocker sendlocker ( & _sendMutex ) ; if ( _clients . contains ( streamName ) ) { clients_t clientListCopy ; { QMutexLocker locker ( & _mutex ) ; clientListCopy = _clients [ streamName ] ; } for ( int i = 0 ; i < clientListCopy . size ( ) ; ++ i ) { QTcpSocket * client = clientListCopy [ i ] ; try { Q_ASSERT ( client -> state ( ) == QAbstractSocket :: ConnectedState ) ; _protocol -> send ( * client , streamName , * blob ) ; client -> flush ( ) ; } catch ( ... ) { std :: cerr << " " << std :: endl ; _killClient ( client ) ; } } } emit sent ( blob ) ; if ( ! _seenTypes . contains ( streamName ) ) { _seenTypes . insert ( streamName ) ; _sendNewDataTypes ( ) ; } }
@details
 Send data to connected clients
@details Send data to connected clients
// Check if there are any client reading streamName type data // Control access to the _clients // Send data to client // kill the client if anything goes wrong // let any blocked sends continue // now the blob is sent. // Ensure we track the data streams and inform any interested // clients of updates.