From 788908b0d21243788a2b49eb9b74fc052ccaea55 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 2 Aug 2008 07:28:21 +0000 Subject: [PATCH] some more work for ping message --- src/channel.cpp | 75 ++++++++++++++++++++++----------------- src/channel.h | 11 +++++- src/client.cpp | 6 ++++ src/client.h | 5 +++ src/clientsettingsdlg.cpp | 6 ++++ src/protocol.h | 2 +- 6 files changed, 71 insertions(+), 34 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index 97476dec..1677d8a6 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2006 + * Copyright (c) 2004-2008 * * Author(s): * Volker Fischer @@ -39,44 +39,52 @@ CChannelSet::CChannelSet() // CODE TAG: MAX_NUM_CHANNELS_TAG // make sure we have MAX_NUM_CHANNELS connections!!! // send message - QObject::connect(&vecChannels[0],SIGNAL(MessReadyForSending(CVector)),this,SLOT(OnSendProtMessCh0(CVector))); - QObject::connect(&vecChannels[1],SIGNAL(MessReadyForSending(CVector)),this,SLOT(OnSendProtMessCh1(CVector))); - QObject::connect(&vecChannels[2],SIGNAL(MessReadyForSending(CVector)),this,SLOT(OnSendProtMessCh2(CVector))); - QObject::connect(&vecChannels[3],SIGNAL(MessReadyForSending(CVector)),this,SLOT(OnSendProtMessCh3(CVector))); - QObject::connect(&vecChannels[4],SIGNAL(MessReadyForSending(CVector)),this,SLOT(OnSendProtMessCh4(CVector))); - QObject::connect(&vecChannels[5],SIGNAL(MessReadyForSending(CVector)),this,SLOT(OnSendProtMessCh5(CVector))); + QObject::connect ( &vecChannels[0], SIGNAL ( MessReadyForSending ( CVector ) ), this, SLOT ( OnSendProtMessCh0 ( CVector ) ) ); + QObject::connect ( &vecChannels[1], SIGNAL ( MessReadyForSending ( CVector ) ), this, SLOT ( OnSendProtMessCh1 ( CVector ) ) ); + QObject::connect ( &vecChannels[2], SIGNAL ( MessReadyForSending ( CVector ) ), this, SLOT ( OnSendProtMessCh2 ( CVector ) ) ); + QObject::connect ( &vecChannels[3], SIGNAL ( MessReadyForSending ( CVector ) ), this, SLOT ( OnSendProtMessCh3 ( CVector ) ) ); + QObject::connect ( &vecChannels[4], SIGNAL ( MessReadyForSending ( CVector ) ), this, SLOT ( OnSendProtMessCh4 ( CVector ) ) ); + QObject::connect ( &vecChannels[5], SIGNAL ( MessReadyForSending ( CVector ) ), this, SLOT ( OnSendProtMessCh5 ( CVector ) ) ); // request jitter buffer size - QObject::connect(&vecChannels[0],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh0())); - QObject::connect(&vecChannels[1],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh1())); - QObject::connect(&vecChannels[2],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh2())); - QObject::connect(&vecChannels[3],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh3())); - QObject::connect(&vecChannels[4],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh4())); - QObject::connect(&vecChannels[5],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh5())); + QObject::connect ( &vecChannels[0], SIGNAL ( NewConnection()), this, SLOT ( OnNewConnectionCh0() ) ); + QObject::connect ( &vecChannels[1], SIGNAL ( NewConnection()), this, SLOT ( OnNewConnectionCh1() ) ); + QObject::connect ( &vecChannels[2], SIGNAL ( NewConnection()), this, SLOT ( OnNewConnectionCh2() ) ); + QObject::connect ( &vecChannels[3], SIGNAL ( NewConnection()), this, SLOT ( OnNewConnectionCh3() ) ); + QObject::connect ( &vecChannels[4], SIGNAL ( NewConnection()), this, SLOT ( OnNewConnectionCh4() ) ); + QObject::connect ( &vecChannels[5], SIGNAL ( NewConnection()), this, SLOT ( OnNewConnectionCh5() ) ); // request connected clients list - QObject::connect(&vecChannels[0],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh0())); - QObject::connect(&vecChannels[1],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh1())); - QObject::connect(&vecChannels[2],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh2())); - QObject::connect(&vecChannels[3],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh3())); - QObject::connect(&vecChannels[4],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh4())); - QObject::connect(&vecChannels[5],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh5())); + QObject::connect ( &vecChannels[0], SIGNAL ( ReqConnClientsList() ), this, SLOT ( OnReqConnClientsListCh0() ) ); + QObject::connect ( &vecChannels[1], SIGNAL ( ReqConnClientsList() ), this, SLOT ( OnReqConnClientsListCh1() ) ); + QObject::connect ( &vecChannels[2], SIGNAL ( ReqConnClientsList() ), this, SLOT ( OnReqConnClientsListCh2() ) ); + QObject::connect ( &vecChannels[3], SIGNAL ( ReqConnClientsList() ), this, SLOT ( OnReqConnClientsListCh3() ) ); + QObject::connect ( &vecChannels[4], SIGNAL ( ReqConnClientsList() ), this, SLOT ( OnReqConnClientsListCh4() ) ); + QObject::connect ( &vecChannels[5], SIGNAL ( ReqConnClientsList() ), this, SLOT ( OnReqConnClientsListCh5() ) ); // channel name has changed - QObject::connect(&vecChannels[0],SIGNAL(NameHasChanged()),this,SLOT(OnNameHasChangedCh0())); - QObject::connect(&vecChannels[1],SIGNAL(NameHasChanged()),this,SLOT(OnNameHasChangedCh1())); - QObject::connect(&vecChannels[2],SIGNAL(NameHasChanged()),this,SLOT(OnNameHasChangedCh2())); - QObject::connect(&vecChannels[3],SIGNAL(NameHasChanged()),this,SLOT(OnNameHasChangedCh3())); - QObject::connect(&vecChannels[4],SIGNAL(NameHasChanged()),this,SLOT(OnNameHasChangedCh4())); - QObject::connect(&vecChannels[5],SIGNAL(NameHasChanged()),this,SLOT(OnNameHasChangedCh5())); + QObject::connect ( &vecChannels[0], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh0() ) ); + QObject::connect ( &vecChannels[1], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh1() ) ); + QObject::connect ( &vecChannels[2], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh2() ) ); + QObject::connect ( &vecChannels[3], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh3() ) ); + QObject::connect ( &vecChannels[4], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh4() ) ); + QObject::connect ( &vecChannels[5], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh5() ) ); - // chate text received - QObject::connect(&vecChannels[0],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh0(QString))); - QObject::connect(&vecChannels[1],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh1(QString))); - QObject::connect(&vecChannels[2],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh2(QString))); - QObject::connect(&vecChannels[3],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh3(QString))); - QObject::connect(&vecChannels[4],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh4(QString))); - QObject::connect(&vecChannels[5],SIGNAL(ChatTextReceived(QString)),this,SLOT(OnChatTextReceivedCh5(QString))); + // chat text received + QObject::connect ( &vecChannels[0], SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceivedCh0 ( QString ) ) ); + QObject::connect ( &vecChannels[1], SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceivedCh1 ( QString ) ) ); + QObject::connect ( &vecChannels[2], SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceivedCh2 ( QString ) ) ); + QObject::connect ( &vecChannels[3], SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceivedCh3 ( QString ) ) ); + QObject::connect ( &vecChannels[4], SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceivedCh4 ( QString ) ) ); + QObject::connect ( &vecChannels[5], SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceivedCh5 ( QString ) ) ); + + // ping message received + QObject::connect ( &vecChannels[0], SIGNAL ( PingReceived ( QTime ) ), this, SLOT ( OnPingReceivedCh0 ( QTime ) ) ); + QObject::connect ( &vecChannels[1], SIGNAL ( PingReceived ( QTime ) ), this, SLOT ( OnPingReceivedCh1 ( QTime ) ) ); + QObject::connect ( &vecChannels[2], SIGNAL ( PingReceived ( QTime ) ), this, SLOT ( OnPingReceivedCh2 ( QTime ) ) ); + QObject::connect ( &vecChannels[3], SIGNAL ( PingReceived ( QTime ) ), this, SLOT ( OnPingReceivedCh3 ( QTime ) ) ); + QObject::connect ( &vecChannels[4], SIGNAL ( PingReceived ( QTime ) ), this, SLOT ( OnPingReceivedCh4 ( QTime ) ) ); + QObject::connect ( &vecChannels[5], SIGNAL ( PingReceived ( QTime ) ), this, SLOT ( OnPingReceivedCh5 ( QTime ) ) ); } CVector CChannelSet::CreateChannelList() @@ -475,6 +483,9 @@ CChannel::CChannel() : sName ( "" ), QObject::connect( &Protocol, SIGNAL ( ChatTextReceived ( QString ) ), this, SIGNAL ( ChatTextReceived ( QString ) ) ); + + QObject::connect( &Protocol, SIGNAL ( PingReceived ( QTime ) ), + this, SIGNAL ( PingReceived ( QTime ) ) ); } void CChannel::SetEnable ( const bool bNEnStat ) diff --git a/src/channel.h b/src/channel.h index 99f6fef6..1d634957 100755 --- a/src/channel.h +++ b/src/channel.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2006 + * Copyright (c) 2004-2008 * * Author(s): * Volker Fischer @@ -118,6 +118,7 @@ public: void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); } void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); } void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); } + void CreatePingMes ( const QTime time ) { Protocol.CreatePingMes ( time ); } void CreateNetwBlSiFactMes ( const int iNetwBlSiFact ) { @@ -194,6 +195,7 @@ signals: void ProtocolStatus ( bool bOk ); void NameHasChanged(); void ChatTextReceived ( QString strChatText ); + void PingReceived ( QTime time ); }; @@ -285,6 +287,13 @@ public slots: void OnChatTextReceivedCh4 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 4, strChatText ); } void OnChatTextReceivedCh5 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 5, strChatText ); } + void OnPingReceivedCh0 ( QTime time ) { vecChannels[0].CreatePingMes ( time ); } + void OnPingReceivedCh1 ( QTime time ) { vecChannels[1].CreatePingMes ( time ); } + void OnPingReceivedCh2 ( QTime time ) { vecChannels[2].CreatePingMes ( time ); } + void OnPingReceivedCh3 ( QTime time ) { vecChannels[3].CreatePingMes ( time ); } + void OnPingReceivedCh4 ( QTime time ) { vecChannels[4].CreatePingMes ( time ); } + void OnPingReceivedCh5 ( QTime time ) { vecChannels[5].CreatePingMes ( time ); } + signals: void MessReadyForSending ( int iChID, CVector vecMessage ); }; diff --git a/src/client.cpp b/src/client.cpp index 66dd1fb9..f0e52866 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -88,6 +88,12 @@ void CClient::OnNewConnection() Channel.CreateReqConnClientsList(); } +void CClient::OnReceivePingMessage ( QTime time ) +{ + // calculate difference between received time and current time + emit PingTimeReceived ( time.msecsTo ( QTime().currentTime() ) ); +} + bool CClient::SetServerAddr ( QString strNAddr ) { QHostAddress InetAddr; diff --git a/src/client.h b/src/client.h index d8b42001..3dfa711c 100755 --- a/src/client.h +++ b/src/client.h @@ -124,6 +124,9 @@ public: void SendTextMess ( const QString& strChatText ) { Channel.CreateChatTextMes ( strChatText ); } + void SendPingMess() + { Channel.CreatePingMes ( QTime().currentTime() ); } + CSound* GetSndInterface() { return &Sound; } CChannel* GetChannel() { return &Channel; } @@ -182,10 +185,12 @@ public slots: void OnReqJittBufSize(); void OnProtocolStatus ( bool bOk ); void OnNewConnection(); + void OnReceivePingMessage ( QTime time ); signals: void ConClientListMesReceived ( CVector vecChanInfo ); void ChatTextReceived ( QString strChatText ); + void PingTimeReceived ( int iPingTime ); }; diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 09680800..d25255bf 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -164,6 +164,12 @@ void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value ) void CClientSettingsDlg::UpdateDisplay() { + + +// TEST +//pClient->SendPingMess(); + + // response time TextLabelStdDevTimer->setText ( QString(). setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" ); diff --git a/src/protocol.h b/src/protocol.h index 0ce34d8e..0c7a07f1 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -1,5 +1,5 @@ /******************************************************************************\ - * Copyright (c) 2004-2006 + * Copyright (c) 2004-2008 * * Author(s): * Volker Fischer