From 24f707f2e7bc48557e72d0774b4fa216ed014c32 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 6 Apr 2011 19:01:39 +0000 Subject: [PATCH] removed connecion less channel class since it is not required --- src/channel.cpp | 22 ---------------------- src/channel.h | 39 --------------------------------------- src/client.cpp | 6 +++--- src/client.h | 4 ++-- src/server.cpp | 16 ++++++++-------- src/server.h | 42 +++++++++++++++++++++--------------------- src/socket.cpp | 6 +++--- src/socket.h | 23 ++++++++++++----------- 8 files changed, 49 insertions(+), 109 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index 0cc93002..0f4c39b2 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -548,25 +548,3 @@ int CChannel::GetUploadRateKbps() 8 /* bits per byte */ * SYSTEM_SAMPLE_RATE_HZ / iAudioSizeOut / 1000; } - - -// CConnectionLessChannel implementation *************************************** -CConnectionLessChannel::CConnectionLessChannel() -{ - // Connections ------------------------------------------------------------- - QObject::connect ( &Protocol, - SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector ) ), - SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector ) ) ); - - QObject::connect( &Protocol, - SIGNAL ( CLPingReceived ( CHostAddress, int ) ), - SIGNAL ( CLPingReceived ( CHostAddress, int ) ) ); - - QObject::connect( &Protocol, - SIGNAL ( CLRegisterServerReceived ( CHostAddress, CServerCoreInfo ) ), - SIGNAL ( CLRegisterServerReceived ( CHostAddress, CServerCoreInfo ) ) ); - - QObject::connect( &Protocol, - SIGNAL ( CLSendEmptyMes ( CHostAddress ) ), - SIGNAL ( CLSendEmptyMes ( CHostAddress ) ) ); -} diff --git a/src/channel.h b/src/channel.h index 3bd0c334..c18775e3 100755 --- a/src/channel.h +++ b/src/channel.h @@ -189,43 +189,4 @@ signals: void Disconnected(); }; - -class CConnectionLessChannel : public QObject -{ - Q_OBJECT - -public: - CConnectionLessChannel(); - - bool ParseConnectionLessMessage ( const CVector& vecbyData, - const int iNumBytes, - const CHostAddress& InetAddr ) - { - return Protocol.ParseConnectionLessMessage ( vecbyData, iNumBytes, InetAddr ); - } - - void CreateCLServerFullMes ( const CHostAddress& InetAddr ) - { Protocol.CreateCLServerFullMes ( InetAddr ); } - - void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ) - { Protocol.CreateCLPingMes ( InetAddr, iMs ); } - - void CreateCLEmptyMes ( const CHostAddress& InetAddr ) - { Protocol.CreateCLEmptyMes ( InetAddr ); } - -protected: - // network protocol - CProtocol Protocol; - -signals: - void CLMessReadyForSending ( CHostAddress InetAddr, - CVector vecMessage ); - - void CLPingReceived ( CHostAddress InetAddr, int iMs ); - void CLRegisterServerReceived ( CHostAddress InetAddr, - CServerCoreInfo ServerInfo ); - void CLSendEmptyMes ( CHostAddress TargetInetAddr ); -}; - - #endif /* !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */ diff --git a/src/client.cpp b/src/client.cpp index a788f0af..42b98f69 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -34,7 +34,7 @@ CClient::CClient ( const quint16 iPortNumber ) : iCeltNumCodedBytes ( CELT_NUM_BYTES_MONO_NORMAL_QUALITY ), bCeltDoHighQuality ( false ), bUseStereo ( false ), - Socket ( &Channel, &ConnLessChannel, iPortNumber ), + Socket ( &Channel, &ConnLessProtocol, iPortNumber ), Sound ( AudioCallback, this ), iAudioInFader ( AUD_FADER_IN_MIDDLE ), bReverbOnLeftChan ( false ), @@ -113,11 +113,11 @@ CClient::CClient ( const quint16 iPortNumber ) : QObject::connect ( &Channel, SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnReceivePingMessage ( int ) ) ); - QObject::connect ( &ConnLessChannel, + QObject::connect ( &ConnLessProtocol, SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector ) ), this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector ) ) ); - QObject::connect ( &ConnLessChannel, SIGNAL ( CLPingReceived ( CHostAddress, int ) ), + QObject::connect ( &ConnLessProtocol, SIGNAL ( CLPingReceived ( CHostAddress, int ) ), this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) ); QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ), diff --git a/src/client.h b/src/client.h index 5d63a44b..3a51eafc 100755 --- a/src/client.h +++ b/src/client.h @@ -212,7 +212,7 @@ public: { Channel.CreatePingMes ( PreparePingMessage() ); }; void SendCLPingMess ( const CHostAddress& InetAddr ) - { ConnLessChannel.CreateCLPingMes ( InetAddr, PreparePingMessage() ); }; + { ConnLessProtocol.CreateCLPingMes ( InetAddr, PreparePingMessage() ); }; int EstimatedOverallDelay ( const int iPingTimeMs ); @@ -241,7 +241,7 @@ protected: // only one channel is needed for client application CChannel Channel; - CConnectionLessChannel ConnLessChannel; + CProtocol ConnLessProtocol; bool bDoAutoSockBufSize; // audio encoder/decoder diff --git a/src/server.cpp b/src/server.cpp index 5f505669..7c37fc02 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -275,19 +275,19 @@ CServer::CServer ( const QString& strLoggingFileName, QObject::connect ( &HighPrecisionTimer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) ); - QObject::connect ( &ConnLessChannel, + QObject::connect ( &ConnLessProtocol, SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector ) ), this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector ) ) ); - QObject::connect ( &ConnLessChannel, + QObject::connect ( &ConnLessProtocol, SIGNAL ( CLPingReceived ( CHostAddress, int ) ), this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) ); - QObject::connect ( &ConnLessChannel, + QObject::connect ( &ConnLessProtocol, SIGNAL ( CLRegisterServerReceived ( CHostAddress, CServerCoreInfo ) ), this, SLOT ( OnCLRegisterServerReceived ( CHostAddress, CServerCoreInfo ) ) ); - QObject::connect ( &ConnLessChannel, + QObject::connect ( &ConnLessProtocol, SIGNAL ( CLSendEmptyMes ( CHostAddress ) ), this, SLOT ( OnCLSendEmptyMes ( CHostAddress ) ) ); @@ -903,9 +903,9 @@ bool CServer::PutData ( const CVector& vecbyRecBuf, { // this is a new client, we then first check if this is a connection // less message before we create a new official channel - if ( ConnLessChannel.ParseConnectionLessMessage ( vecbyRecBuf, - iNumBytesRead, - HostAdr ) ) + if ( ConnLessProtocol.ParseConnectionLessMessage ( vecbyRecBuf, + iNumBytesRead, + HostAdr ) ) { // a new client is calling, look for free channel iCurChanID = GetFreeChan(); @@ -939,7 +939,7 @@ bool CServer::PutData ( const CVector& vecbyRecBuf, bChanOK = false; // create and send "server full" message - ConnLessChannel.CreateCLServerFullMes ( HostAdr ); + ConnLessProtocol.CreateCLServerFullMes ( HostAdr ); } } } diff --git a/src/server.h b/src/server.h index 707e9364..4dec9083 100755 --- a/src/server.h +++ b/src/server.h @@ -152,37 +152,37 @@ protected: // do not use the vector class since CChannel does not have appropriate // copy constructor/operator - CChannel vecChannels[MAX_NUM_CHANNELS]; - CConnectionLessChannel ConnLessChannel; - QMutex Mutex; + CChannel vecChannels[MAX_NUM_CHANNELS]; + CProtocol ConnLessProtocol; + QMutex Mutex; // audio encoder/decoder - CELTMode* CeltModeMono[MAX_NUM_CHANNELS]; - CELTEncoder* CeltEncoderMono[MAX_NUM_CHANNELS]; - CELTDecoder* CeltDecoderMono[MAX_NUM_CHANNELS]; - CELTMode* CeltModeStereo[MAX_NUM_CHANNELS]; - CELTEncoder* CeltEncoderStereo[MAX_NUM_CHANNELS]; - CELTDecoder* CeltDecoderStereo[MAX_NUM_CHANNELS]; + CELTMode* CeltModeMono[MAX_NUM_CHANNELS]; + CELTEncoder* CeltEncoderMono[MAX_NUM_CHANNELS]; + CELTDecoder* CeltDecoderMono[MAX_NUM_CHANNELS]; + CELTMode* CeltModeStereo[MAX_NUM_CHANNELS]; + CELTEncoder* CeltEncoderStereo[MAX_NUM_CHANNELS]; + CELTDecoder* CeltDecoderStereo[MAX_NUM_CHANNELS]; - CVector vstrChatColors; + CVector vstrChatColors; // actual working objects - CSocket Socket; - CCycleTimeVariance CycleTimeVariance; + CSocket Socket; + CCycleTimeVariance CycleTimeVariance; // logging - CServerLogging Logging; + CServerLogging Logging; // HTML file server status - bool bWriteStatusHTMLFile; - QString strServerHTMLFileListName; - QString strServerNameWithPort; + bool bWriteStatusHTMLFile; + QString strServerHTMLFileListName; + QString strServerNameWithPort; - CHighPrecisionTimer HighPrecisionTimer; - CVector vecsSendData; + CHighPrecisionTimer HighPrecisionTimer; + CVector vecsSendData; // server list - CServerListManager ServerListManager; + CServerListManager ServerListManager; public slots: void OnTimer(); @@ -190,10 +190,10 @@ public slots: void OnSendCLProtMessage ( CHostAddress InetAddr, CVector vecMessage ); void OnCLPingReceived ( CHostAddress InetAddr, int iMs ) - { ConnLessChannel.CreateCLPingMes ( InetAddr, iMs ); } + { ConnLessProtocol.CreateCLPingMes ( InetAddr, iMs ); } void OnCLSendEmptyMes ( CHostAddress TargetInetAddr ) - { ConnLessChannel.CreateCLEmptyMes ( TargetInetAddr ); } + { ConnLessProtocol.CreateCLEmptyMes ( TargetInetAddr ); } void OnCLRegisterServerReceived ( CHostAddress InetAddr, CServerCoreInfo ServerInfo ) diff --git a/src/socket.cpp b/src/socket.cpp index 446d6b02..3d7c8eb1 100755 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -111,9 +111,9 @@ void CSocket::OnDataReceived() { // this is an unknown address, try to parse connection less // message - pConnLessChannel->ParseConnectionLessMessage ( vecbyRecBuf, - iNumBytesRead, - RecHostAddr ); + pConnLessProtocol->ParseConnectionLessMessage ( vecbyRecBuf, + iNumBytesRead, + RecHostAddr ); // do not perform any other action on this received packet return; diff --git a/src/socket.h b/src/socket.h index a86f3d91..59780368 100755 --- a/src/socket.h +++ b/src/socket.h @@ -33,6 +33,7 @@ #include #include "global.h" #include "channel.h" +#include "protocol.h" #include "util.h" // The header file server.h requires to include this header file so we get a @@ -47,10 +48,10 @@ class CSocket : public QObject Q_OBJECT public: - CSocket ( CChannel* pNewChannel, - CConnectionLessChannel* pNewCLChannel, + CSocket ( CChannel* pNewChannel, + CProtocol* pNewCLProtocol, const quint16 iPortNumber ) - : pChannel( pNewChannel ), pConnLessChannel ( pNewCLChannel ), + : pChannel( pNewChannel ), pConnLessProtocol ( pNewCLProtocol ), bIsClient ( true ) { Init ( iPortNumber ); } CSocket ( CServer* pNServP, @@ -63,17 +64,17 @@ public: protected: void Init ( const quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER ); - QUdpSocket SocketDevice; - QMutex Mutex; + QUdpSocket SocketDevice; + QMutex Mutex; - CVector vecbyRecBuf; - CHostAddress RecHostAddr; + CVector vecbyRecBuf; + CHostAddress RecHostAddr; - CChannel* pChannel; // for client - CConnectionLessChannel* pConnLessChannel; // for client - CServer* pServer; // for server + CChannel* pChannel; // for client + CProtocol* pConnLessProtocol; // for client + CServer* pServer; // for server - bool bIsClient; + bool bIsClient; public slots: void OnDataReceived();