00001
00002 #include "srcp_virtual_client.h"
00003
00004 SrcpVirtualClient::SrcpVirtualClient( QObject* parent ) : VirtualClient( parent )
00005 {
00006 _infoClient = new SrcpSocket( "INFO", this ) ;
00007 _commandClient = new SrcpSocket( "COMMAND", this ) ;
00008
00009 connect( _infoClient, SIGNAL( connected() ),
00010 this , SLOT( srcpHandshake() ) ) ;
00011 connect( _infoClient, SIGNAL( infoReceived ( QString ) ),
00012 this, SLOT( parseInfo( QString ) ) ) ;
00013 connect( _infoClient, SIGNAL( infoReceived ( QString ) ),
00014 this, SIGNAL( infoReceived( QString ) ) ) ;
00015 connect( _commandClient, SIGNAL( errorOccured( QString ) ),
00016 parent, SLOT( reportError( QString ) ) ) ;
00017 connect( _commandClient, SIGNAL( connected() ),
00018 this , SLOT( srcpHandshake() ) ) ;
00019 }
00020
00021 SrcpVirtualClient::~SrcpVirtualClient()
00022 {
00023 setConnection( FALSE ) ;
00024 }
00025
00026 SrcpSocket* SrcpVirtualClient::commandClient()
00027 {
00028 return _commandClient ;
00029 }
00030
00031 void SrcpVirtualClient::setConnection( const bool &c )
00032 {
00033 if( c && _infoClient->state() != QAbstractSocket::ConnectedState && _infoClient->state() != QAbstractSocket::ConnectedState )
00034 {
00035 _infoClient->connectToHost( _serverAddress, _serverPort ) ;
00036 _commandClient->connectToHost( _serverAddress, _serverPort ) ;
00037 }
00038 else
00039 {
00040 _infoClient->threadSafeDisconnectFromHost() ;
00041 _commandClient->disconnectFromHost() ;
00042 }
00043
00044 }