prepared everything for transmitting/receiving the first connection less ping time measurement

This commit is contained in:
Volker Fischer 2011-03-30 07:55:43 +00:00
parent 0cff6af6d8
commit 9feff9057a
13 changed files with 123 additions and 39 deletions

View File

@ -97,8 +97,9 @@ CChannelFader::CChannelFader ( QWidget* pNW,
QObject::connect ( pcbMute, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnMuteStateChanged ( int ) ) );
QObject::connect ( pcbSolo, SIGNAL ( stateChanged ( int ) ),
this, SIGNAL ( soloStateChanged ( int ) ) );
QObject::connect ( pcbSolo,
SIGNAL ( stateChanged ( int ) ),
SIGNAL ( soloStateChanged ( int ) ) );
}
void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign )

View File

@ -84,11 +84,13 @@ CChannel::CChannel ( const bool bNIsServer ) :
QObject::connect( &Protocol, SIGNAL ( ChangeChanName ( QString ) ),
this, SLOT ( OnChangeChanName ( QString ) ) );
QObject::connect( &Protocol, SIGNAL ( ChatTextReceived ( QString ) ),
this, SIGNAL ( ChatTextReceived ( QString ) ) );
QObject::connect( &Protocol,
SIGNAL ( ChatTextReceived ( QString ) ),
SIGNAL ( ChatTextReceived ( QString ) ) );
QObject::connect( &Protocol, SIGNAL ( PingReceived ( int ) ),
this, SIGNAL ( PingReceived ( int ) ) );
QObject::connect( &Protocol,
SIGNAL ( PingReceived ( int ) ),
SIGNAL ( PingReceived ( int ) ) );
QObject::connect ( &Protocol,
SIGNAL ( NetTranspPropsReceived ( CNetworkTransportProps ) ),
@ -555,4 +557,8 @@ CConnectionLessChannel::CConnectionLessChannel()
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 ) ) );
}

View File

@ -209,6 +209,9 @@ public:
void CreateCLServerFullMes ( const CHostAddress& InetAddr )
{ Protocol.CreateCLServerFullMes ( InetAddr ); }
void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs )
{ Protocol.CreateCLPingMes ( InetAddr, iMs ); }
protected:
// network protocol
CProtocol Protocol;
@ -216,6 +219,8 @@ protected:
signals:
void CLMessReadyForSending ( CHostAddress InetAddr,
CVector<uint8_t> vecMessage );
void CLPingReceived ( CHostAddress InetAddr, int iMs );
};

View File

@ -34,7 +34,7 @@ CClient::CClient ( const quint16 iPortNumber ) :
iCeltNumCodedBytes ( CELT_NUM_BYTES_MONO_NORMAL_QUALITY ),
bCeltDoHighQuality ( false ),
bUseStereo ( false ),
Socket ( &Channel, iPortNumber ),
Socket ( &Channel, &ConnLessChannel, iPortNumber ),
Sound ( AudioCallback, this ),
iAudioInFader ( AUD_FADER_IN_MIDDLE ),
bReverbOnLeftChan ( false ),
@ -89,10 +89,6 @@ CClient::CClient ( const quint16 iPortNumber ) :
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
this, SLOT ( OnSendProtMessage ( CVector<uint8_t> ) ) );
QObject::connect ( &ConnLessChannel,
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ),
this, SLOT ( OnReqJittBufSize() ) );
@ -110,12 +106,20 @@ CClient::CClient ( const quint16 iPortNumber ) :
QObject::connect ( &Channel, SIGNAL ( NewConnection() ),
this, SLOT ( OnNewConnection() ) );
QObject::connect ( &Channel, SIGNAL ( ChatTextReceived ( QString ) ),
this, SIGNAL ( ChatTextReceived ( QString ) ) );
QObject::connect ( &Channel,
SIGNAL ( ChatTextReceived ( QString ) ),
SIGNAL ( ChatTextReceived ( QString ) ) );
QObject::connect ( &Channel, SIGNAL ( PingReceived ( int ) ),
this, SLOT ( OnReceivePingMessage ( int ) ) );
QObject::connect ( &ConnLessChannel,
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
QObject::connect ( &ConnLessChannel, SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) );
QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ),
this, SLOT ( OnSndCrdReinitRequest() ) );
}
@ -162,6 +166,17 @@ void CClient::OnReceivePingMessage ( int iMs )
}
}
void CClient::OnCLPingReceived ( CHostAddress InetAddr, int iMs )
{
// calculate difference between received time in ms and current time in ms,
// take care of wrap arounds (if wrapping, do not use result)
const int iCurDiff = PreciseTime.elapsed() - iMs;
if ( iCurDiff >= 0 )
{
emit CLPingTimeReceived ( InetAddr, iCurDiff );
}
}
bool CClient::SetServerAddr ( QString strNAddr )
{
QHostAddress InetAddr;

View File

@ -212,6 +212,9 @@ public:
void SendPingMess()
{ Channel.CreatePingMes ( PreciseTime.elapsed() ); };
void SendCLPingMess ( const CHostAddress& InetAddr )
{ ConnLessChannel.CreateCLPingMes ( InetAddr, PreciseTime.elapsed() ); };
int EstimatedOverallDelay ( const int iPingTimeMs );
CChannel* GetChannel() { return &Channel; }
@ -293,17 +296,21 @@ protected:
public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); }
void OnReqChanName() { Channel.SetRemoteName ( strName ); }
void OnNewConnection();
void OnReceivePingMessage ( int iMs );
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnCLPingReceived ( CHostAddress InetAddr, int iMs );
void OnSndCrdReinitRequest();
signals:
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ChatTextReceived ( QString strChatText );
void PingTimeReceived ( int iPingTime );
void CLPingTimeReceived ( CHostAddress InetAddr, int iPingTime );
void Disconnected();
void Stopped();
};

View File

@ -26,8 +26,9 @@
/* Implementation *************************************************************/
CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f ) :
QDialog ( parent, f )
CConnectDlg::CConnectDlg ( CClient* pNCliP, QWidget* parent,
Qt::WindowFlags f )
: QDialog ( parent, f ), pClient ( pNCliP )
{
setupUi ( this );
@ -44,7 +45,8 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f ) :
ListViewServers->setColumnWidth ( 3, 80 );
ListViewServers->clear();
// TEST
pListViewItem = new QTreeWidgetItem ( ListViewServers );
//TextLabelPingTime->setText ( "" );
@ -71,12 +73,18 @@ void CConnectDlg::hideEvent ( QHideEvent* )
void CConnectDlg::OnTimerPing()
{
// send ping message to server
// pClient->SendPingMess();
// TEST
//pClient->SendCLPingMess ( pClient->GetChannel()->
// const CHostAddress& InetAddr );
}
void CConnectDlg::OnPingTimeResult ( int iPingTime )
void CConnectDlg::SetPingTimeResult ( CHostAddress& InetAddr,
const int iPingTime )
{
// TODO
// TextLabelPingTime->setText ( sErrorText );
}
// TEST
pListViewItem->setText ( 0, QString().setNum ( iPingTime ) );
}

View File

@ -28,6 +28,7 @@
#include <qwhatsthis.h>
#include <qtimer.h>
#include "global.h"
#include "client.h"
#ifdef _WIN32
# include "../windows/moc/connectdlgbase.h"
#else
@ -45,15 +46,22 @@ class CConnectDlg : public QDialog, private Ui_CConnectDlgBase
Q_OBJECT
public:
CConnectDlg ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
CConnectDlg ( CClient* pNCliP, QWidget* parent = 0, Qt::WindowFlags f = 0 );
void AddPingTime ( QString strChatText );
void SetPingTimeResult ( CHostAddress& InetAddr, const int iPingTime );
protected:
QTimer TimerPing;
virtual void showEvent ( QShowEvent* );
virtual void hideEvent ( QHideEvent* );
void OnPingTimeResult ( int iPingTime );
CClient* pClient;
QTimer TimerPing;
// TEST
QTreeWidgetItem* pListViewItem;
public slots:
void OnTimerPing();

View File

@ -46,7 +46,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
, Qt::WindowMinMaxButtonsHint
#endif
),
ConnectDlg ( parent
ConnectDlg ( pNCliP, parent
#ifdef _WIN32
// this somehow only works reliable on Windows
, Qt::WindowMinMaxButtonsHint
@ -421,6 +421,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ),
this, SLOT ( OnPingTimeResult ( int ) ) );
QObject::connect ( pClient, SIGNAL ( CLPingTimeReceived ( CHostAddress, int ) ),
this, SLOT ( OnCLPingTimeResult ( CHostAddress, int ) ) );
QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ),
this, SLOT ( OnGUIDesignChanged() ) );
@ -753,6 +756,17 @@ void CLlconClientDlg::OnPingTimeResult ( int iPingTime )
LEDDelay->SetLight ( iOverallDelayLEDColor );
}
void CLlconClientDlg::OnCLPingTimeResult ( CHostAddress InetAddr,
int iPingTime )
{
// TODO evaluate the background color for the ping time result in the
// table in this function (see function above, there also the LED color
// is calculated so we do the other here, too)
ConnectDlg.SetPingTimeResult ( InetAddr, iPingTime );
}
void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
{
// start/stop client, set button text

View File

@ -110,6 +110,7 @@ public slots:
void OnTimerStatus() { UpdateDisplay(); }
void OnTimerPing();
void OnPingTimeResult ( int iPingTime );
void OnCLPingTimeResult ( CHostAddress InetAddr, int iPingTime );
void OnOpenGeneralSettings();
void OnOpenChatDialog() { ShowChatWindow(); }
void OnSliderAudInFader ( int value );

View File

@ -276,6 +276,10 @@ CServer::CServer ( const QString& strLoggingFileName,
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
QObject::connect ( &ConnLessChannel,
SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) );
// CODE TAG: MAX_NUM_CHANNELS_TAG
// make sure we have MAX_NUM_CHANNELS connections!!!
// send message

View File

@ -182,6 +182,8 @@ public slots:
void OnTimer();
void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage );
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnCLPingReceived ( CHostAddress InetAddr, int iMs )
{ ConnLessChannel.CreateCLPingMes ( InetAddr, iMs ); }
// CODE TAG: MAX_NUM_CHANNELS_TAG
// make sure we have MAX_NUM_CHANNELS connections!!!

View File

@ -1,5 +1,5 @@
/******************************************************************************\
* opyright (c) 2004-2011
* Copyright (c) 2004-2011
*
* Author(s):
* Volker Fischer
@ -103,6 +103,13 @@ void CSocket::OnDataReceived()
// check if packet comes from the server we want to connect
if ( !( pChannel->GetAddress() == RecHostAddr ) )
{
// this is an unknown address, try to parse connection less
// message
pConnLessChannel->ParseConnectionLessMessage ( vecbyRecBuf,
iNumBytesRead,
RecHostAddr );
// do not perform any other action on this received packet
return;
}

View File

@ -46,11 +46,16 @@ class CSocket : public QObject
Q_OBJECT
public:
CSocket ( CChannel* pNewChannel, const quint16 iPortNumber ) :
pChannel( pNewChannel ), bIsClient ( true ) { Init ( iPortNumber ); }
CSocket ( CServer* pNServP, const quint16 iPortNumber ) :
pServer ( pNServP ), bIsClient ( false )
{ Init ( iPortNumber ); }
CSocket ( CChannel* pNewChannel,
CConnectionLessChannel* pNewCLChannel,
const quint16 iPortNumber )
: pChannel( pNewChannel ), pConnLessChannel ( pNewCLChannel ),
bIsClient ( true ) { Init ( iPortNumber ); }
CSocket ( CServer* pNServP,
const quint16 iPortNumber )
: pServer ( pNServP ), bIsClient ( false ) { Init ( iPortNumber ); }
virtual ~CSocket() {}
void SendPacket ( const CVector<uint8_t>& vecbySendBuf,
@ -59,15 +64,16 @@ public:
protected:
void Init ( const quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER );
QUdpSocket SocketDevice;
QUdpSocket SocketDevice;
CVector<uint8_t> vecbyRecBuf;
CHostAddress RecHostAddr;
CVector<uint8_t> vecbyRecBuf;
CHostAddress RecHostAddr;
CChannel* pChannel; // for client
CServer* pServer; // for server
CChannel* pChannel; // for client
CConnectionLessChannel* pConnLessChannel; // for client
CServer* pServer; // for server
bool bIsClient;
bool bIsClient;
public slots:
void OnDataReceived();