replaced normal ping messages with connection less ping message to avoid all the acknowledge messages
This commit is contained in:
parent
3b8a04a829
commit
49070c77c1
10 changed files with 42 additions and 113 deletions
|
@ -89,10 +89,6 @@ CChannel::CChannel ( const bool bNIsServer ) :
|
|||
SIGNAL ( ChatTextReceived ( QString ) ),
|
||||
SIGNAL ( ChatTextReceived ( QString ) ) );
|
||||
|
||||
QObject::connect( &Protocol,
|
||||
SIGNAL ( PingReceived ( int ) ),
|
||||
SIGNAL ( PingReceived ( int ) ) );
|
||||
|
||||
QObject::connect ( &Protocol,
|
||||
SIGNAL ( DetectedCLMessage ( CVector<uint8_t>, int ) ),
|
||||
SIGNAL ( DetectedCLMessage ( CVector<uint8_t>, int ) ) );
|
||||
|
|
|
@ -130,7 +130,6 @@ void UpdateSocketBufferSize ( const double dAudioBufferDurationMs,
|
|||
void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); }
|
||||
void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); }
|
||||
void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); }
|
||||
void CreatePingMes ( const int iMs ) { Protocol.CreatePingMes ( iMs ); }
|
||||
|
||||
void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo )
|
||||
{
|
||||
|
@ -194,7 +193,6 @@ signals:
|
|||
void NameHasChanged();
|
||||
void ReqChanName();
|
||||
void ChatTextReceived ( QString strChatText );
|
||||
void PingReceived ( int iMs );
|
||||
void ReqNetTranspProps();
|
||||
void Disconnected();
|
||||
void DetectedCLMessage ( CVector<uint8_t> vecbyData,
|
||||
|
|
|
@ -108,9 +108,6 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
|||
SIGNAL ( ChatTextReceived ( QString ) ),
|
||||
SIGNAL ( ChatTextReceived ( QString ) ) );
|
||||
|
||||
QObject::connect ( &Channel, SIGNAL ( PingReceived ( int ) ),
|
||||
this, SLOT ( OnReceivePingMessage ( int ) ) );
|
||||
|
||||
QObject::connect ( &ConnLessProtocol,
|
||||
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
|
||||
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
|
||||
|
@ -119,6 +116,10 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
|||
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ),
|
||||
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) );
|
||||
|
||||
QObject::connect ( &ConnLessProtocol,
|
||||
SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
|
||||
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) );
|
||||
|
||||
QObject::connect ( &ConnLessProtocol,
|
||||
SIGNAL ( CLPingWithNumClientsReceived ( CHostAddress, int, int ) ),
|
||||
this, SLOT ( OnCLPingWithNumClientsReceived ( CHostAddress, int, int ) ) );
|
||||
|
@ -168,13 +169,18 @@ void CClient::OnNewConnection()
|
|||
Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() );
|
||||
}
|
||||
|
||||
void CClient::OnReceivePingMessage ( int iMs )
|
||||
void CClient::OnCLPingReceived ( CHostAddress InetAddr,
|
||||
int iMs )
|
||||
{
|
||||
// take care of wrap arounds (if wrapping, do not use result)
|
||||
const int iCurDiff = EvaluatePingMessage ( iMs );
|
||||
if ( iCurDiff >= 0 )
|
||||
// make sure we are running and the server address is correct
|
||||
if ( IsRunning() && ( InetAddr == Channel.GetAddress() ) )
|
||||
{
|
||||
emit PingTimeReceived ( iCurDiff );
|
||||
// take care of wrap arounds (if wrapping, do not use result)
|
||||
const int iCurDiff = EvaluatePingMessage ( iMs );
|
||||
if ( iCurDiff >= 0 )
|
||||
{
|
||||
emit PingTimeReceived ( iCurDiff );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
12
src/client.h
12
src/client.h
|
@ -224,13 +224,8 @@ public:
|
|||
void CreateChatTextMes ( const QString& strChatText )
|
||||
{ Channel.CreateChatTextMes ( strChatText ); }
|
||||
|
||||
void CreatePingMes()
|
||||
{ Channel.CreatePingMes ( PreparePingMessage() ); }
|
||||
|
||||
// TODO
|
||||
//void CreateCLPingMes ( const CHostAddress& InetAddr )
|
||||
// { ConnLessProtocol.CreateCLPingMes ( InetAddr, PreparePingMessage() ); }
|
||||
|
||||
void CreateCLPingMes()
|
||||
{ ConnLessProtocol.CreateCLPingMes ( Channel.GetAddress(), PreparePingMessage() ); }
|
||||
|
||||
void CreateCLServerListPingMes ( const CHostAddress& InetAddr )
|
||||
{
|
||||
|
@ -331,7 +326,8 @@ public slots:
|
|||
void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); }
|
||||
void OnReqChanName() { Channel.SetRemoteName ( strName ); }
|
||||
void OnNewConnection();
|
||||
void OnReceivePingMessage ( int iMs );
|
||||
void OnCLPingReceived ( CHostAddress InetAddr,
|
||||
int iMs );
|
||||
|
||||
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
|
||||
void OnCLPingWithNumClientsReceived ( CHostAddress InetAddr,
|
||||
|
|
|
@ -641,8 +641,8 @@ void CLlconClientDlg::OnTimerSigMet()
|
|||
|
||||
void CLlconClientDlg::OnTimerPing()
|
||||
{
|
||||
// send ping message to server
|
||||
pClient->CreatePingMes();
|
||||
// send ping message to the server
|
||||
pClient->CreateCLPingMes();
|
||||
}
|
||||
|
||||
void CLlconClientDlg::OnPingTimeResult ( int iPingTime )
|
||||
|
|
|
@ -102,13 +102,6 @@ MESSAGES (with connection)
|
|||
+------------------+----------------------+
|
||||
|
||||
|
||||
- PROTMESSID_PING_MS: Ping message (for measuring the ping time)
|
||||
|
||||
+-----------------------------+
|
||||
| 4 bytes transmit time in ms |
|
||||
+-----------------------------+
|
||||
|
||||
|
||||
- PROTMESSID_NETW_TRANSPORT_PROPS: Properties for network transport
|
||||
|
||||
+------------------------+-------------------------+-----------------+ ...
|
||||
|
@ -525,10 +518,6 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false;
|
|||
bRet = EvaluateChatTextMes ( vecData );
|
||||
break;
|
||||
|
||||
case PROTMESSID_PING_MS:
|
||||
bRet = EvaluatePingMes ( vecData );
|
||||
break;
|
||||
|
||||
case PROTMESSID_NETW_TRANSPORT_PROPS:
|
||||
bRet = EvaluateNetwTranspPropsMes ( vecData );
|
||||
break;
|
||||
|
@ -924,35 +913,6 @@ bool CProtocol::EvaluateChatTextMes ( const CVector<uint8_t>& vecData )
|
|||
return false; // no error
|
||||
}
|
||||
|
||||
void CProtocol::CreatePingMes ( const int iMs )
|
||||
{
|
||||
int iPos = 0; // init position pointer
|
||||
|
||||
// build data vector (4 bytes long)
|
||||
CVector<uint8_t> vecData ( 4 );
|
||||
|
||||
// transmit time (4 bytes)
|
||||
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iMs ), 4 );
|
||||
|
||||
CreateAndSendMessage ( PROTMESSID_PING_MS, vecData );
|
||||
}
|
||||
|
||||
bool CProtocol::EvaluatePingMes ( const CVector<uint8_t>& vecData )
|
||||
{
|
||||
int iPos = 0; // init position pointer
|
||||
|
||||
// check size
|
||||
if ( vecData.Size() != 4 )
|
||||
{
|
||||
return true; // return error code
|
||||
}
|
||||
|
||||
// invoke message action
|
||||
emit PingReceived ( static_cast<int> ( GetValFromStream ( vecData, iPos, 4 ) ) );
|
||||
|
||||
return false; // no error
|
||||
}
|
||||
|
||||
void CProtocol::CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps )
|
||||
{
|
||||
int iPos = 0; // init position pointer
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#define PROTMESSID_REQ_CONN_CLIENTS_LIST 16 // request connected client list
|
||||
#define PROTMESSID_CHANNEL_NAME 17 // set channel name for fader tag
|
||||
#define PROTMESSID_CHAT_TEXT 18 // contains a chat text
|
||||
#define PROTMESSID_PING_MS 19 // for measuring ping time
|
||||
#define PROTMESSID_PING_MS 19 // OLD (not used anymore)
|
||||
#define PROTMESSID_NETW_TRANSPORT_PROPS 20 // properties for network transport
|
||||
#define PROTMESSID_REQ_NETW_TRANSPORT_PROPS 21 // request properties for network transport
|
||||
#define PROTMESSID_DISCONNECTION 22 // OLD (not used anymore)
|
||||
|
@ -93,7 +93,6 @@ public:
|
|||
void CreateChanNameMes ( const QString strName );
|
||||
void CreateReqChanNameMes();
|
||||
void CreateChatTextMes ( const QString strChatText );
|
||||
void CreatePingMes ( const int iMs );
|
||||
void CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps );
|
||||
void CreateReqNetwTranspPropsMes();
|
||||
|
||||
|
@ -204,7 +203,6 @@ protected:
|
|||
bool EvaluateChanNameMes ( const CVector<uint8_t>& vecData );
|
||||
bool EvaluateReqChanNameMes();
|
||||
bool EvaluateChatTextMes ( const CVector<uint8_t>& vecData );
|
||||
bool EvaluatePingMes ( const CVector<uint8_t>& vecData );
|
||||
bool EvaluateNetwTranspPropsMes ( const CVector<uint8_t>& vecData );
|
||||
bool EvaluateReqNetwTranspPropsMes();
|
||||
|
||||
|
@ -252,7 +250,6 @@ signals:
|
|||
void ChangeChanName ( QString strName );
|
||||
void ReqChanName();
|
||||
void ChatTextReceived ( QString strChatText );
|
||||
void PingReceived ( int iMs );
|
||||
void NetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps );
|
||||
void ReqNetTranspProps();
|
||||
|
||||
|
|
|
@ -284,6 +284,10 @@ CServer::CServer ( const int iNewNumChan,
|
|||
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
|
||||
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
|
||||
|
||||
QObject::connect ( &ConnLessProtocol,
|
||||
SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
|
||||
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) );
|
||||
|
||||
QObject::connect ( &ConnLessProtocol,
|
||||
SIGNAL ( CLPingWithNumClientsReceived ( CHostAddress, int, int ) ),
|
||||
this, SLOT ( OnCLPingWithNumClientsReceived ( CHostAddress, int, int ) ) );
|
||||
|
@ -394,20 +398,6 @@ CServer::CServer ( const int iNewNumChan,
|
|||
QObject::connect ( &vecChannels[9], SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceivedCh9 ( QString ) ) );
|
||||
QObject::connect ( &vecChannels[10], SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceivedCh10 ( QString ) ) );
|
||||
QObject::connect ( &vecChannels[11], SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceivedCh11 ( QString ) ) );
|
||||
|
||||
// ping message received
|
||||
QObject::connect ( &vecChannels[0], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh0 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[1], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh1 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[2], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh2 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[3], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh3 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[4], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh4 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[5], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh5 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[6], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh6 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[7], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh7 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[8], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh8 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[9], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh9 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[10], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh10 ( int ) ) );
|
||||
QObject::connect ( &vecChannels[11], SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnPingReceivedCh11 ( int ) ) );
|
||||
}
|
||||
|
||||
void CServer::OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage )
|
||||
|
|
16
src/server.h
16
src/server.h
|
@ -249,6 +249,9 @@ public slots:
|
|||
const int iNumBytes,
|
||||
const CHostAddress& InetAddr );
|
||||
|
||||
void OnCLPingReceived ( CHostAddress InetAddr, int iMs )
|
||||
{ ConnLessProtocol.CreateCLPingMes ( InetAddr, iMs ); }
|
||||
|
||||
void OnCLPingWithNumClientsReceived ( CHostAddress InetAddr,
|
||||
int iMs,
|
||||
int )
|
||||
|
@ -366,19 +369,6 @@ public slots:
|
|||
void OnChatTextReceivedCh9 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 9, strChatText ); }
|
||||
void OnChatTextReceivedCh10 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 10, strChatText ); }
|
||||
void OnChatTextReceivedCh11 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 11, strChatText ); }
|
||||
|
||||
void OnPingReceivedCh0 ( int iMs ) { vecChannels[0].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh1 ( int iMs ) { vecChannels[1].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh2 ( int iMs ) { vecChannels[2].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh3 ( int iMs ) { vecChannels[3].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh4 ( int iMs ) { vecChannels[4].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh5 ( int iMs ) { vecChannels[5].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh6 ( int iMs ) { vecChannels[6].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh7 ( int iMs ) { vecChannels[7].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh8 ( int iMs ) { vecChannels[8].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh9 ( int iMs ) { vecChannels[9].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh10 ( int iMs ) { vecChannels[10].CreatePingMes ( iMs ); }
|
||||
void OnPingReceivedCh11 ( int iMs ) { vecChannels[11].CreatePingMes ( iMs ); }
|
||||
};
|
||||
|
||||
#endif /* !defined ( SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ ) */
|
||||
|
|
|
@ -101,7 +101,7 @@ public slots:
|
|||
CHostAddress CurHostAddress ( QHostAddress ( sAddress ), iPort );
|
||||
|
||||
// generate random protocol message
|
||||
switch ( GenRandomIntInRange ( 0, 22 ) )
|
||||
switch ( GenRandomIntInRange ( 0, 21 ) )
|
||||
{
|
||||
case 0:
|
||||
Protocol.CreateJitBufMes ( GenRandomIntInRange ( 0, 10 ) );
|
||||
|
@ -141,10 +141,6 @@ public slots:
|
|||
break;
|
||||
|
||||
case 8:
|
||||
Protocol.CreatePingMes ( GenRandomIntInRange ( 0, 100000 ) );
|
||||
break;
|
||||
|
||||
case 9:
|
||||
NetTrProps.eAudioCodingType =
|
||||
static_cast<EAudComprType> ( GenRandomIntInRange ( 0, 2 ) );
|
||||
|
||||
|
@ -158,26 +154,26 @@ public slots:
|
|||
Protocol.CreateNetwTranspPropsMes ( NetTrProps );
|
||||
break;
|
||||
|
||||
case 10:
|
||||
case 9:
|
||||
Protocol.CreateReqNetwTranspPropsMes();
|
||||
break;
|
||||
|
||||
case 11:
|
||||
case 10:
|
||||
Protocol.CreateCLPingMes ( CurHostAddress,
|
||||
GenRandomIntInRange ( -2, 1000 ) );
|
||||
break;
|
||||
|
||||
case 12:
|
||||
case 11:
|
||||
Protocol.CreateCLPingWithNumClientsMes ( CurHostAddress,
|
||||
GenRandomIntInRange ( -2, 1000 ),
|
||||
GenRandomIntInRange ( -2, 1000 ) );
|
||||
break;
|
||||
|
||||
case 13:
|
||||
case 12:
|
||||
Protocol.CreateCLServerFullMes ( CurHostAddress );
|
||||
break;
|
||||
|
||||
case 14:
|
||||
case 13:
|
||||
ServerInfo.bPermanentOnline =
|
||||
static_cast<bool> ( GenRandomIntInRange ( 0, 1 ) );
|
||||
|
||||
|
@ -194,11 +190,11 @@ public slots:
|
|||
ServerInfo );
|
||||
break;
|
||||
|
||||
case 15:
|
||||
case 14:
|
||||
Protocol.CreateCLUnregisterServerMes ( CurHostAddress );
|
||||
break;
|
||||
|
||||
case 16:
|
||||
case 15:
|
||||
vecServerInfo[0].bPermanentOnline =
|
||||
static_cast<bool> ( GenRandomIntInRange ( 0, 1 ) );
|
||||
|
||||
|
@ -216,29 +212,29 @@ public slots:
|
|||
vecServerInfo );
|
||||
break;
|
||||
|
||||
case 17:
|
||||
case 16:
|
||||
Protocol.CreateCLReqServerListMes ( CurHostAddress );
|
||||
break;
|
||||
|
||||
case 18:
|
||||
case 17:
|
||||
Protocol.CreateCLSendEmptyMesMes ( CurHostAddress,
|
||||
CurHostAddress );
|
||||
break;
|
||||
|
||||
case 19:
|
||||
case 18:
|
||||
Protocol.CreateCLEmptyMes ( CurHostAddress );
|
||||
break;
|
||||
|
||||
case 20:
|
||||
case 19:
|
||||
Protocol.CreateCLDisconnection ( CurHostAddress );
|
||||
break;
|
||||
|
||||
case 21:
|
||||
case 20:
|
||||
Protocol.CreateAndImmSendAcknMess ( GenRandomIntInRange ( -10, 100 ),
|
||||
GenRandomIntInRange ( -100, 100 ) );
|
||||
break;
|
||||
|
||||
case 22:
|
||||
case 21:
|
||||
// arbitrary "audio" packet (with random sizes)
|
||||
CVector<uint8_t> vecMessage ( GenRandomIntInRange ( 1, 1000 ) );
|
||||
OnSendProtMessage ( vecMessage );
|
||||
|
|
Loading…
Reference in a new issue