removed connecion less channel class since it is not required
This commit is contained in:
parent
1f1e36876e
commit
24f707f2e7
8 changed files with 49 additions and 109 deletions
|
@ -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<uint8_t> ) ),
|
||||
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ) );
|
||||
|
||||
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 ) ) );
|
||||
}
|
||||
|
|
|
@ -189,43 +189,4 @@ signals:
|
|||
void Disconnected();
|
||||
};
|
||||
|
||||
|
||||
class CConnectionLessChannel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CConnectionLessChannel();
|
||||
|
||||
bool ParseConnectionLessMessage ( const CVector<uint8_t>& 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<uint8_t> 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_ ) */
|
||||
|
|
|
@ -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<uint8_t> ) ),
|
||||
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
|
||||
|
||||
QObject::connect ( &ConnLessChannel, SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
|
||||
QObject::connect ( &ConnLessProtocol, SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
|
||||
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) );
|
||||
|
||||
QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ),
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<uint8_t> ) ),
|
||||
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
|
||||
|
||||
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<uint8_t>& 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<uint8_t>& vecbyRecBuf,
|
|||
bChanOK = false;
|
||||
|
||||
// create and send "server full" message
|
||||
ConnLessChannel.CreateCLServerFullMes ( HostAdr );
|
||||
ConnLessProtocol.CreateCLServerFullMes ( HostAdr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
42
src/server.h
42
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<QString> vstrChatColors;
|
||||
CVector<QString> 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<short> vecsSendData;
|
||||
CHighPrecisionTimer HighPrecisionTimer;
|
||||
CVector<short> vecsSendData;
|
||||
|
||||
// server list
|
||||
CServerListManager ServerListManager;
|
||||
CServerListManager ServerListManager;
|
||||
|
||||
public slots:
|
||||
void OnTimer();
|
||||
|
@ -190,10 +190,10 @@ public slots:
|
|||
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> 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 )
|
||||
|
|
|
@ -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;
|
||||
|
|
23
src/socket.h
23
src/socket.h
|
@ -33,6 +33,7 @@
|
|||
#include <vector>
|
||||
#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<uint8_t> vecbyRecBuf;
|
||||
CHostAddress RecHostAddr;
|
||||
CVector<uint8_t> 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();
|
||||
|
|
Loading…
Reference in a new issue