the number of connected clients are now not managed with the server list but by the connection less ping time message

This commit is contained in:
Volker Fischer 2011-04-25 10:51:57 +00:00
parent c4e0e6e000
commit 23d79c5f85
13 changed files with 2878 additions and 2799 deletions

View File

@ -114,8 +114,9 @@ CClient::CClient ( const quint16 iPortNumber ) :
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ), SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ),
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) ); SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) );
QObject::connect ( &ConnLessProtocol, SIGNAL ( CLPingReceived ( CHostAddress, int ) ), QObject::connect ( &ConnLessProtocol,
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) ); SIGNAL ( CLPingWithNumClientsReceived ( CHostAddress, int, int ) ),
this, SLOT ( OnCLPingWithNumClientsReceived ( CHostAddress, int, int ) ) );
QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ), QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ),
this, SLOT ( OnSndCrdReinitRequest() ) ); this, SLOT ( OnSndCrdReinitRequest() ) );
@ -162,13 +163,17 @@ void CClient::OnReceivePingMessage ( int iMs )
} }
} }
void CClient::OnCLPingReceived ( CHostAddress InetAddr, int iMs ) void CClient::OnCLPingWithNumClientsReceived ( CHostAddress InetAddr,
int iMs,
int iNumClients )
{ {
// take care of wrap arounds (if wrapping, do not use result) // take care of wrap arounds (if wrapping, do not use result)
const int iCurDiff = EvaluatePingMessage ( iMs ); const int iCurDiff = EvaluatePingMessage ( iMs );
if ( iCurDiff >= 0 ) if ( iCurDiff >= 0 )
{ {
emit CLPingTimeReceived ( InetAddr, iCurDiff ); emit CLPingTimeWithNumClientsReceived ( InetAddr,
iCurDiff,
iNumClients );
} }
} }

View File

@ -1,325 +1,329 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2011 * Copyright (c) 2004-2011
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
* *
****************************************************************************** ******************************************************************************
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later * Foundation; either version 2 of the License, or (at your option) any later
* version. * version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., * this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
\******************************************************************************/ \******************************************************************************/
#if !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) #if !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ )
#define CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ #define CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_
#include <qglobal.h> #include <qglobal.h>
#include <qhostaddress.h> #include <qhostaddress.h>
#include <qhostinfo.h> #include <qhostinfo.h>
#include <qstring.h> #include <qstring.h>
#include <qdatetime.h> #include <qdatetime.h>
#include <qmessagebox.h> #include <qmessagebox.h>
#include "celt.h" #include "celt.h"
#include "global.h" #include "global.h"
#include "socket.h" #include "socket.h"
#include "channel.h" #include "channel.h"
#include "util.h" #include "util.h"
#include "buffer.h" #include "buffer.h"
#ifdef LLCON_VST_PLUGIN #ifdef LLCON_VST_PLUGIN
# include "vstsound.h" # include "vstsound.h"
#else #else
# ifdef _WIN32 # ifdef _WIN32
# include "../windows/sound.h" # include "../windows/sound.h"
# else # else
# if defined ( __APPLE__ ) || defined ( __MACOSX ) # if defined ( __APPLE__ ) || defined ( __MACOSX )
# include "../mac/sound.h" # include "../mac/sound.h"
# else # else
# include "../linux/sound.h" # include "../linux/sound.h"
# include <sched.h> # include <sched.h>
# include <socket.h> # include <socket.h>
# include <netdb.h> # include <netdb.h>
# endif # endif
# endif # endif
#endif #endif
/* Definitions ****************************************************************/ /* Definitions ****************************************************************/
// audio in fader range // audio in fader range
#define AUD_FADER_IN_MIN 0 #define AUD_FADER_IN_MIN 0
#define AUD_FADER_IN_MAX 100 #define AUD_FADER_IN_MAX 100
#define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 ) #define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 )
// audio reverberation range // audio reverberation range
#define AUD_REVERB_MAX 100 #define AUD_REVERB_MAX 100
// CELT number of coded bytes per audio packet // CELT number of coded bytes per audio packet
// 24: mono low/normal quality 156 kbsp (128) / 114 kbps (256) // 24: mono low/normal quality 156 kbsp (128) / 114 kbps (256)
// 44: mono high quality 216 kbps (128) / 174 kbps (256) // 44: mono high quality 216 kbps (128) / 174 kbps (256)
#define CELT_NUM_BYTES_MONO_NORMAL_QUALITY 24 #define CELT_NUM_BYTES_MONO_NORMAL_QUALITY 24
#define CELT_NUM_BYTES_MONO_HIGH_QUALITY 44 #define CELT_NUM_BYTES_MONO_HIGH_QUALITY 44
// 46: stereo low/normal quality 222 kbsp (128) / 180 kbps (256) // 46: stereo low/normal quality 222 kbsp (128) / 180 kbps (256)
// 70: stereo high quality 294 kbps (128) / 252 kbps (256) // 70: stereo high quality 294 kbps (128) / 252 kbps (256)
#define CELT_NUM_BYTES_STEREO_NORMAL_QUALITY 46 #define CELT_NUM_BYTES_STEREO_NORMAL_QUALITY 46
#define CELT_NUM_BYTES_STEREO_HIGH_QUALITY 70 #define CELT_NUM_BYTES_STEREO_HIGH_QUALITY 70
/* Classes ********************************************************************/ /* Classes ********************************************************************/
class CClient : public QObject class CClient : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
CClient ( const quint16 iPortNumber ); CClient ( const quint16 iPortNumber );
void Start(); void Start();
void Stop(); void Stop();
bool IsRunning() { return Sound.IsRunning(); } bool IsRunning() { return Sound.IsRunning(); }
bool SetServerAddr ( QString strNAddr ); bool SetServerAddr ( QString strNAddr );
double MicLevelL() { return SignalLevelMeter.MicLevelLeft(); } double MicLevelL() { return SignalLevelMeter.MicLevelLeft(); }
double MicLevelR() { return SignalLevelMeter.MicLevelRight(); } double MicLevelR() { return SignalLevelMeter.MicLevelRight(); }
bool IsConnected() { return Channel.IsConnected(); } bool IsConnected() { return Channel.IsConnected(); }
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); } double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
bool GetOpenChatOnNewMessage() const { return bOpenChatOnNewMessage; } bool GetOpenChatOnNewMessage() const { return bOpenChatOnNewMessage; }
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; } void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
EGUIDesign GetGUIDesign() const { return eGUIDesign; } EGUIDesign GetGUIDesign() const { return eGUIDesign; }
void SetGUIDesign ( const EGUIDesign bNGD ) { eGUIDesign = bNGD; } void SetGUIDesign ( const EGUIDesign bNGD ) { eGUIDesign = bNGD; }
bool GetCELTHighQuality() const { return bCeltDoHighQuality; } bool GetCELTHighQuality() const { return bCeltDoHighQuality; }
void SetCELTHighQuality ( const bool bNCeltHighQualityFlag ); void SetCELTHighQuality ( const bool bNCeltHighQualityFlag );
bool GetUseStereo() const { return bUseStereo; } bool GetUseStereo() const { return bUseStereo; }
void SetUseStereo ( const bool bNUseStereo ); void SetUseStereo ( const bool bNUseStereo );
int GetAudioInFader() const { return iAudioInFader; } int GetAudioInFader() const { return iAudioInFader; }
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; } void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
int GetReverbLevel() const { return iReverbLevel; } int GetReverbLevel() const { return iReverbLevel; }
void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; } void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; }
bool IsReverbOnLeftChan() const { return bReverbOnLeftChan; } bool IsReverbOnLeftChan() const { return bReverbOnLeftChan; }
void SetReverbOnLeftChan ( const bool bIL ) void SetReverbOnLeftChan ( const bool bIL )
{ {
bReverbOnLeftChan = bIL; bReverbOnLeftChan = bIL;
AudioReverbL.Clear(); AudioReverbL.Clear();
AudioReverbR.Clear(); AudioReverbR.Clear();
} }
void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; } void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; }
bool GetDoAutoSockBufSize() const { return bDoAutoSockBufSize; } bool GetDoAutoSockBufSize() const { return bDoAutoSockBufSize; }
void SetSockBufNumFrames ( const int iNumBlocks ) void SetSockBufNumFrames ( const int iNumBlocks )
{ {
// only change parameter if new parameter is different from current one // only change parameter if new parameter is different from current one
if ( Channel.GetSockBufNumFrames() != iNumBlocks ) if ( Channel.GetSockBufNumFrames() != iNumBlocks )
{ {
// set the new socket size (number of frames) // set the new socket size (number of frames)
if ( !Channel.SetSockBufNumFrames ( iNumBlocks ) ) if ( !Channel.SetSockBufNumFrames ( iNumBlocks ) )
{ {
// if setting of socket buffer size was successful, // if setting of socket buffer size was successful,
// tell the server that size has changed // tell the server that size has changed
Channel.CreateJitBufMes ( iNumBlocks ); Channel.CreateJitBufMes ( iNumBlocks );
} }
} }
} }
int GetSockBufNumFrames() { return Channel.GetSockBufNumFrames(); } int GetSockBufNumFrames() { return Channel.GetSockBufNumFrames(); }
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); } int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
// sound card device selection // sound card device selection
int GetSndCrdNumDev() { return Sound.GetNumDev(); } int GetSndCrdNumDev() { return Sound.GetNumDev(); }
QString GetSndCrdDeviceName ( const int iDiD ) QString GetSndCrdDeviceName ( const int iDiD )
{ return Sound.GetDeviceName ( iDiD ); } { return Sound.GetDeviceName ( iDiD ); }
QString SetSndCrdDev ( const int iNewDev ); QString SetSndCrdDev ( const int iNewDev );
int GetSndCrdDev() { return Sound.GetDev(); } int GetSndCrdDev() { return Sound.GetDev(); }
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); } void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
// sound card channel selection // sound card channel selection
int GetSndCrdNumInputChannels() { return Sound.GetNumInputChannels(); } int GetSndCrdNumInputChannels() { return Sound.GetNumInputChannels(); }
QString GetSndCrdInputChannelName ( const int iDiD ) { return Sound.GetInputChannelName ( iDiD ); } QString GetSndCrdInputChannelName ( const int iDiD ) { return Sound.GetInputChannelName ( iDiD ); }
void SetSndCrdLeftInputChannel ( const int iNewChan ); void SetSndCrdLeftInputChannel ( const int iNewChan );
void SetSndCrdRightInputChannel ( const int iNewChan ); void SetSndCrdRightInputChannel ( const int iNewChan );
int GetSndCrdLeftInputChannel() { return Sound.GetLeftInputChannel(); } int GetSndCrdLeftInputChannel() { return Sound.GetLeftInputChannel(); }
int GetSndCrdRightInputChannel() { return Sound.GetRightInputChannel(); } int GetSndCrdRightInputChannel() { return Sound.GetRightInputChannel(); }
int GetSndCrdNumOutputChannels() { return Sound.GetNumOutputChannels(); } int GetSndCrdNumOutputChannels() { return Sound.GetNumOutputChannels(); }
QString GetSndCrdOutputChannelName ( const int iDiD ) { return Sound.GetOutputChannelName ( iDiD ); } QString GetSndCrdOutputChannelName ( const int iDiD ) { return Sound.GetOutputChannelName ( iDiD ); }
void SetSndCrdLeftOutputChannel ( const int iNewChan ); void SetSndCrdLeftOutputChannel ( const int iNewChan );
void SetSndCrdRightOutputChannel ( const int iNewChan ); void SetSndCrdRightOutputChannel ( const int iNewChan );
int GetSndCrdLeftOutputChannel() { return Sound.GetLeftOutputChannel(); } int GetSndCrdLeftOutputChannel() { return Sound.GetLeftOutputChannel(); }
int GetSndCrdRightOutputChannel() { return Sound.GetRightOutputChannel(); } int GetSndCrdRightOutputChannel() { return Sound.GetRightOutputChannel(); }
void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor ); void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor );
int GetSndCrdPrefFrameSizeFactor() int GetSndCrdPrefFrameSizeFactor()
{ return iSndCrdPrefFrameSizeFactor; } { return iSndCrdPrefFrameSizeFactor; }
int GetSndCrdActualMonoBlSize() int GetSndCrdActualMonoBlSize()
{ {
// the actual sound card mono block size depends on whether a // the actual sound card mono block size depends on whether a
// sound card conversion buffer is used or not // sound card conversion buffer is used or not
if ( bSndCrdConversionBufferRequired ) if ( bSndCrdConversionBufferRequired )
{ {
return iSndCardMonoBlockSizeSamConvBuff; return iSndCardMonoBlockSizeSamConvBuff;
} }
else else
{ {
return iMonoBlockSizeSam; return iMonoBlockSizeSam;
} }
} }
int GetSystemMonoBlSize() { return iMonoBlockSizeSam; } int GetSystemMonoBlSize() { return iMonoBlockSizeSam; }
int GetSndCrdConvBufAdditionalDelayMonoBlSize() int GetSndCrdConvBufAdditionalDelayMonoBlSize()
{ {
if ( bSndCrdConversionBufferRequired ) if ( bSndCrdConversionBufferRequired )
{ {
// by introducing the conversion buffer we also introduce additional // by introducing the conversion buffer we also introduce additional
// delay which equals the "internal" mono buffer size // delay which equals the "internal" mono buffer size
return iMonoBlockSizeSam; return iMonoBlockSizeSam;
} }
else else
{ {
return 0; return 0;
} }
} }
bool GetFraSiFactPrefSupported() { return bFraSiFactPrefSupported; } bool GetFraSiFactPrefSupported() { return bFraSiFactPrefSupported; }
bool GetFraSiFactDefSupported() { return bFraSiFactDefSupported; } bool GetFraSiFactDefSupported() { return bFraSiFactDefSupported; }
bool GetFraSiFactSafeSupported() { return bFraSiFactSafeSupported; } bool GetFraSiFactSafeSupported() { return bFraSiFactSafeSupported; }
void SetRemoteChanGain ( const int iId, const double dGain ) void SetRemoteChanGain ( const int iId, const double dGain )
{ Channel.SetRemoteChanGain ( iId, dGain ); } { Channel.SetRemoteChanGain ( iId, dGain ); }
void SetRemoteName() { Channel.SetRemoteName ( strName ); } void SetRemoteName() { Channel.SetRemoteName ( strName ); }
void CreateChatTextMes ( const QString& strChatText ) void CreateChatTextMes ( const QString& strChatText )
{ Channel.CreateChatTextMes ( strChatText ); } { Channel.CreateChatTextMes ( strChatText ); }
void CreatePingMes() void CreatePingMes()
{ Channel.CreatePingMes ( PreparePingMessage() ); } { Channel.CreatePingMes ( PreparePingMessage() ); }
void CreateCLPingMes ( const CHostAddress& InetAddr ) void CreateCLPingMes ( const CHostAddress& InetAddr )
{ ConnLessProtocol.CreateCLPingMes ( InetAddr, PreparePingMessage() ); } { ConnLessProtocol.CreateCLPingMes ( InetAddr, PreparePingMessage() ); }
void CreateCLReqServerListMes ( const CHostAddress& InetAddr ) void CreateCLReqServerListMes ( const CHostAddress& InetAddr )
{ ConnLessProtocol.CreateCLReqServerListMes ( InetAddr ); } { ConnLessProtocol.CreateCLReqServerListMes ( InetAddr ); }
int EstimatedOverallDelay ( const int iPingTimeMs ); int EstimatedOverallDelay ( const int iPingTimeMs );
CChannel* GetChannel() { return &Channel; } CChannel* GetChannel() { return &Channel; }
// settings // settings
CVector<QString> vstrIPAddress; CVector<QString> vstrIPAddress;
QString strName; QString strName;
#ifdef LLCON_VST_PLUGIN #ifdef LLCON_VST_PLUGIN
// VST version must have direct access to sound object // VST version must have direct access to sound object
CSound* GetSound() { return &Sound; } CSound* GetSound() { return &Sound; }
#endif #endif
protected: protected:
// callback function must be static, otherwise it does not work // callback function must be static, otherwise it does not work
static void AudioCallback ( CVector<short>& psData, void* arg ); static void AudioCallback ( CVector<short>& psData, void* arg );
void Init(); void Init();
void ProcessSndCrdAudioData ( CVector<short>& vecsStereoSndCrd ); void ProcessSndCrdAudioData ( CVector<short>& vecsStereoSndCrd );
void ProcessAudioDataIntern ( CVector<short>& vecsStereoSndCrd ); void ProcessAudioDataIntern ( CVector<short>& vecsStereoSndCrd );
void UpdateSocketBufferSize(); void UpdateSocketBufferSize();
int PreparePingMessage(); int PreparePingMessage();
int EvaluatePingMessage ( const int iMs ); int EvaluatePingMessage ( const int iMs );
// only one channel is needed for client application // only one channel is needed for client application
CChannel Channel; CChannel Channel;
CProtocol ConnLessProtocol; CProtocol ConnLessProtocol;
bool bDoAutoSockBufSize; bool bDoAutoSockBufSize;
// audio encoder/decoder // audio encoder/decoder
CELTMode* CeltModeMono; CELTMode* CeltModeMono;
CELTEncoder* CeltEncoderMono; CELTEncoder* CeltEncoderMono;
CELTDecoder* CeltDecoderMono; CELTDecoder* CeltDecoderMono;
CELTMode* CeltModeStereo; CELTMode* CeltModeStereo;
CELTEncoder* CeltEncoderStereo; CELTEncoder* CeltEncoderStereo;
CELTDecoder* CeltDecoderStereo; CELTDecoder* CeltDecoderStereo;
int iCeltNumCodedBytes; int iCeltNumCodedBytes;
bool bCeltDoHighQuality; bool bCeltDoHighQuality;
bool bUseStereo; bool bUseStereo;
CVector<unsigned char> vecCeltData; CVector<unsigned char> vecCeltData;
CSocket Socket; CSocket Socket;
CSound Sound; CSound Sound;
CStereoSignalLevelMeter SignalLevelMeter; CStereoSignalLevelMeter SignalLevelMeter;
CVector<uint8_t> vecbyNetwData; CVector<uint8_t> vecbyNetwData;
int iAudioInFader; int iAudioInFader;
bool bReverbOnLeftChan; bool bReverbOnLeftChan;
int iReverbLevel; int iReverbLevel;
CAudioReverb AudioReverbL; CAudioReverb AudioReverbL;
CAudioReverb AudioReverbR; CAudioReverb AudioReverbR;
int iSndCrdPrefFrameSizeFactor; int iSndCrdPrefFrameSizeFactor;
int iSndCrdFrameSizeFactor; int iSndCrdFrameSizeFactor;
bool bSndCrdConversionBufferRequired; bool bSndCrdConversionBufferRequired;
int iSndCardMonoBlockSizeSamConvBuff; int iSndCardMonoBlockSizeSamConvBuff;
CBufferBase<int16_t> SndCrdConversionBufferIn; CBufferBase<int16_t> SndCrdConversionBufferIn;
CBufferBase<int16_t> SndCrdConversionBufferOut; CBufferBase<int16_t> SndCrdConversionBufferOut;
CVector<int16_t> vecDataConvBuf; CVector<int16_t> vecDataConvBuf;
bool bFraSiFactPrefSupported; bool bFraSiFactPrefSupported;
bool bFraSiFactDefSupported; bool bFraSiFactDefSupported;
bool bFraSiFactSafeSupported; bool bFraSiFactSafeSupported;
int iMonoBlockSizeSam; int iMonoBlockSizeSam;
int iStereoBlockSizeSam; int iStereoBlockSizeSam;
bool bOpenChatOnNewMessage; bool bOpenChatOnNewMessage;
EGUIDesign eGUIDesign; EGUIDesign eGUIDesign;
CVector<int16_t> vecsAudioSndCrdMono; CVector<int16_t> vecsAudioSndCrdMono;
CVector<double> vecdAudioStereo; CVector<double> vecdAudioStereo;
CVector<int16_t> vecsNetwork; CVector<int16_t> vecsNetwork;
// for ping measurement // for ping measurement
CPreciseTime PreciseTime; CPreciseTime PreciseTime;
CCycleTimeVariance CycleTimeVariance; CCycleTimeVariance CycleTimeVariance;
public slots: public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage ); void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); } void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); }
void OnReqChanName() { Channel.SetRemoteName ( strName ); } void OnReqChanName() { Channel.SetRemoteName ( strName ); }
void OnNewConnection(); void OnNewConnection();
void OnReceivePingMessage ( int iMs ); void OnReceivePingMessage ( int iMs );
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage ); void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnCLPingReceived ( CHostAddress InetAddr, int iMs ); void OnCLPingWithNumClientsReceived ( CHostAddress InetAddr,
int iMs,
void OnSndCrdReinitRequest(); int iNumClients );
signals: void OnSndCrdReinitRequest();
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ChatTextReceived ( QString strChatText ); signals:
void PingTimeReceived ( int iPingTime ); void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void CLServerListReceived ( CHostAddress InetAddr, void ChatTextReceived ( QString strChatText );
CVector<CServerInfo> vecServerInfo ); void PingTimeReceived ( int iPingTime );
void CLPingTimeReceived ( CHostAddress InetAddr, int iPingTime ); void CLServerListReceived ( CHostAddress InetAddr,
void Disconnected(); CVector<CServerInfo> vecServerInfo );
void Stopped(); void CLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
}; int iPingTime,
int iNumClients );
#endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */ void Disconnected();
void Stopped();
};
#endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */

View File

@ -234,13 +234,16 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr,
CurPingTimeFont.setBold ( true ); CurPingTimeFont.setBold ( true );
pNewListViewItem->setFont ( 1, CurPingTimeFont ); pNewListViewItem->setFont ( 1, CurPingTimeFont );
// number of clients // server location (city and country)
pNewListViewItem->setText ( 2, QString strLocation = vecServerInfo[iIdx].strCity;
QString().setNum ( vecServerInfo[iIdx].iNumClients ) ); if ( !strLocation.isEmpty() )
{
strLocation += ", ";
}
strLocation +=
QLocale::countryToString ( vecServerInfo[iIdx].eCountry );
// server country pNewListViewItem->setText ( 3, strLocation );
pNewListViewItem->setText ( 3,
QLocale::countryToString ( vecServerInfo[iIdx].eCountry ) );
// store host address // store host address
pNewListViewItem->setData ( 0, Qt::UserRole, pNewListViewItem->setData ( 0, Qt::UserRole,
@ -294,9 +297,10 @@ void CConnectDlg::OnTimerPing()
} }
} }
void CConnectDlg::SetPingTimeResult ( CHostAddress& InetAddr, void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
const int iPingTime, const int iPingTime,
const int iPingTimeLEDColor ) const int iPingTimeLEDColor,
const int iNumClients )
{ {
// apply the received ping time to the correct server list entry // apply the received ping time to the correct server list entry
const int iServerListLen = ListViewServers->topLevelItemCount(); const int iServerListLen = ListViewServers->topLevelItemCount();
@ -332,6 +336,10 @@ void CConnectDlg::SetPingTimeResult ( CHostAddress& InetAddr,
ListViewServers->topLevelItem ( iIdx )-> ListViewServers->topLevelItem ( iIdx )->
setText ( 1, QString().setNum ( iPingTime ) + " ms" ); setText ( 1, QString().setNum ( iPingTime ) + " ms" );
// update number of clients text
ListViewServers->topLevelItem ( iIdx )->
setText ( 2, QString().setNum ( iNumClients ) );
// a ping time was received, set item to visible // a ping time was received, set item to visible
ListViewServers->topLevelItem ( iIdx )->setHidden ( false ); ListViewServers->topLevelItem ( iIdx )->setHidden ( false );
} }

View File

@ -61,9 +61,10 @@ public:
void LoadStoredServers ( const CVector<QString>& vstrNewIPAddresses ); void LoadStoredServers ( const CVector<QString>& vstrNewIPAddresses );
void SetPingTimeResult ( CHostAddress& InetAddr, void SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
const int iPingTime, const int iPingTime,
const int iPingTimeLEDColor ); const int iPingTimeLEDColor,
const int iNumClients );
bool GetStateOK() const { return bStateOK; } bool GetStateOK() const { return bStateOK; }
bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; } bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; }

View File

@ -389,8 +389,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ), SIGNAL ( CLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ),
this, SLOT ( OnCLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) ); this, SLOT ( OnCLServerListReceived ( CHostAddress, CVector<CServerInfo> ) ) );
QObject::connect ( pClient, SIGNAL ( CLPingTimeReceived ( CHostAddress, int ) ), QObject::connect ( pClient,
this, SLOT ( OnCLPingTimeResult ( CHostAddress, int ) ) ); SIGNAL ( CLPingTimeWithNumClientsReceived ( CHostAddress, int, int ) ),
this, SLOT ( OnCLPingTimeWithNumClientsReceived ( CHostAddress, int, int ) ) );
QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ), QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ),
this, SLOT ( OnGUIDesignChanged() ) ); this, SLOT ( OnGUIDesignChanged() ) );
@ -698,8 +699,9 @@ void CLlconClientDlg::OnPingTimeResult ( int iPingTime )
LEDDelay->SetLight ( iOverallDelayLEDColor ); LEDDelay->SetLight ( iOverallDelayLEDColor );
} }
void CLlconClientDlg::OnCLPingTimeResult ( CHostAddress InetAddr, void CLlconClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
int iPingTime ) int iPingTime,
int iNumClients )
{ {
// color definition: <= 25 ms green, <= 50 ms yellow, otherwise red // color definition: <= 25 ms green, <= 50 ms yellow, otherwise red
int iPingTimeLEDColor; int iPingTimeLEDColor;
@ -720,9 +722,10 @@ void CLlconClientDlg::OnCLPingTimeResult ( CHostAddress InetAddr,
} }
// update connection dialog server list // update connection dialog server list
ConnectDlg.SetPingTimeResult ( InetAddr, ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr,
iPingTime, iPingTime,
iPingTimeLEDColor ); iPingTimeLEDColor,
iNumClients );
} }
void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart ) void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )

View File

@ -115,7 +115,9 @@ public slots:
void OnTimerPing(); void OnTimerPing();
void OnPingTimeResult ( int iPingTime ); void OnPingTimeResult ( int iPingTime );
void OnCLPingTimeResult ( CHostAddress InetAddr, int iPingTime ); void OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
int iPingTime,
int iNumClients );
void OnOpenGeneralSettings(); void OnOpenGeneralSettings();
void OnOpenChatDialog() void OnOpenChatDialog()

File diff suppressed because it is too large Load Diff

View File

@ -1,259 +1,268 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2011 * Copyright (c) 2004-2011
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
* *
****************************************************************************** ******************************************************************************
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later * Foundation; either version 2 of the License, or (at your option) any later
* version. * version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., * this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
\******************************************************************************/ \******************************************************************************/
#if !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) #if !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ )
#define PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ #define PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_
#include <qglobal.h> #include <qglobal.h>
#include <qmutex.h> #include <qmutex.h>
#include <qtimer.h> #include <qtimer.h>
#include <qdatetime.h> #include <qdatetime.h>
#include <list> #include <list>
#include "global.h" #include "global.h"
#include "util.h" #include "util.h"
/* Definitions ****************************************************************/ /* Definitions ****************************************************************/
// protocol message IDs // protocol message IDs
#define PROTMESSID_ILLEGAL 0 // illegal ID #define PROTMESSID_ILLEGAL 0 // illegal ID
#define PROTMESSID_ACKN 1 // acknowledge #define PROTMESSID_ACKN 1 // acknowledge
#define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size #define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size
#define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size #define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size
#define PROTMESSID_NET_BLSI_FACTOR 12 // OLD (not used anymore) #define PROTMESSID_NET_BLSI_FACTOR 12 // OLD (not used anymore)
#define PROTMESSID_CHANNEL_GAIN 13 // set channel gain for mix #define PROTMESSID_CHANNEL_GAIN 13 // set channel gain for mix
#define PROTMESSID_CONN_CLIENTS_LIST 14 // connected client list #define PROTMESSID_CONN_CLIENTS_LIST 14 // connected client list
#define PROTMESSID_SERVER_FULL 15 // OLD (not used anymore) #define PROTMESSID_SERVER_FULL 15 // OLD (not used anymore)
#define PROTMESSID_REQ_CONN_CLIENTS_LIST 16 // request connected client list #define PROTMESSID_REQ_CONN_CLIENTS_LIST 16 // request connected client list
#define PROTMESSID_CHANNEL_NAME 17 // set channel name for fader tag #define PROTMESSID_CHANNEL_NAME 17 // set channel name for fader tag
#define PROTMESSID_CHAT_TEXT 18 // contains a chat text #define PROTMESSID_CHAT_TEXT 18 // contains a chat text
#define PROTMESSID_PING_MS 19 // for measuring ping time #define PROTMESSID_PING_MS 19 // for measuring ping time
#define PROTMESSID_NETW_TRANSPORT_PROPS 20 // properties for network transport #define PROTMESSID_NETW_TRANSPORT_PROPS 20 // properties for network transport
#define PROTMESSID_REQ_NETW_TRANSPORT_PROPS 21 // request properties for network transport #define PROTMESSID_REQ_NETW_TRANSPORT_PROPS 21 // request properties for network transport
#define PROTMESSID_DISCONNECTION 22 // disconnection #define PROTMESSID_DISCONNECTION 22 // disconnection
#define PROTMESSID_REQ_CHANNEL_NAME 23 // request channel name for fader tag #define PROTMESSID_REQ_CHANNEL_NAME 23 // request channel name for fader tag
// message IDs of connection less messages (CLM) // message IDs of connection less messages (CLM)
// DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID // DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID
#define PROTMESSID_CLM_PING_MS 1001 // for measuring ping time #define PROTMESSID_CLM_PING_MS 1001 // for measuring ping time
#define PROTMESSID_CLM_SERVER_FULL 1002 // server full message #define PROTMESSID_CLM_PING_MS_WITHNUMCLIENTS 1002 // for ping time and num. of clients info
#define PROTMESSID_CLM_REGISTER_SERVER 1003 // register server #define PROTMESSID_CLM_SERVER_FULL 1003 // server full message
#define PROTMESSID_CLM_UNREGISTER_SERVER 1004 // unregister server -> TODO #define PROTMESSID_CLM_REGISTER_SERVER 1004 // register server
#define PROTMESSID_CLM_SERVER_LIST 1005 // server list #define PROTMESSID_CLM_UNREGISTER_SERVER 1005 // unregister server -> TODO
#define PROTMESSID_CLM_REQ_SERVER_LIST 1006 // request server list #define PROTMESSID_CLM_SERVER_LIST 1006 // server list
#define PROTMESSID_CLM_SEND_EMPTY_MESSAGE 1007 // an empty message shall be send #define PROTMESSID_CLM_REQ_SERVER_LIST 1007 // request server list
#define PROTMESSID_CLM_EMPTY_MESSAGE 1008 // empty message #define PROTMESSID_CLM_SEND_EMPTY_MESSAGE 1008 // an empty message shall be send
#define PROTMESSID_CLM_EMPTY_MESSAGE 1009 // empty message
// lengths of message as defined in protocol.cpp file
#define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2) // lengths of message as defined in protocol.cpp file
#define MESS_LEN_WITHOUT_DATA_BYTE ( MESS_HEADER_LENGTH_BYTE + 2 /* CRC (2) */ ) #define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2)
#define MESS_LEN_WITHOUT_DATA_BYTE ( MESS_HEADER_LENGTH_BYTE + 2 /* CRC (2) */ )
// time out for message re-send if no acknowledgement was received
#define SEND_MESS_TIMEOUT_MS 400 // ms // time out for message re-send if no acknowledgement was received
#define SEND_MESS_TIMEOUT_MS 400 // ms
/* Classes ********************************************************************/
class CProtocol : public QObject /* Classes ********************************************************************/
{ class CProtocol : public QObject
Q_OBJECT {
Q_OBJECT
public:
CProtocol(); public:
CProtocol();
void Reset();
void Reset();
void CreateJitBufMes ( const int iJitBufSize );
void CreateReqJitBufMes(); void CreateJitBufMes ( const int iJitBufSize );
void CreateChanGainMes ( const int iChanID, const double dGain ); void CreateReqJitBufMes();
void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo ); void CreateChanGainMes ( const int iChanID, const double dGain );
void CreateReqConnClientsList(); void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo );
void CreateChanNameMes ( const QString strName ); void CreateReqConnClientsList();
void CreateReqChanNameMes(); void CreateChanNameMes ( const QString strName );
void CreateChatTextMes ( const QString strChatText ); void CreateReqChanNameMes();
void CreatePingMes ( const int iMs ); void CreateChatTextMes ( const QString strChatText );
void CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps ); void CreatePingMes ( const int iMs );
void CreateReqNetwTranspPropsMes(); void CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps );
void CreateReqNetwTranspPropsMes();
void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs );
void CreateCLServerFullMes ( const CHostAddress& InetAddr ); void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs );
void CreateCLRegisterServerMes ( const CHostAddress& InetAddr, void CreateCLPingWithNumClientsMes ( const CHostAddress& InetAddr,
const CServerCoreInfo& ServerInfo ); const int iMs,
void CreateCLServerListMes ( const CHostAddress& InetAddr, const int iNumClients );
const CVector<CServerInfo> vecServerInfo ); void CreateCLServerFullMes ( const CHostAddress& InetAddr );
void CreateCLReqServerListMes ( const CHostAddress& InetAddr ); void CreateCLRegisterServerMes ( const CHostAddress& InetAddr,
void CreateCLSendEmptyMesMes ( const CHostAddress& InetAddr, const CServerCoreInfo& ServerInfo );
const CHostAddress& TargetInetAddr ); void CreateCLServerListMes ( const CHostAddress& InetAddr,
void CreateCLEmptyMes ( const CHostAddress& InetAddr ); const CVector<CServerInfo> vecServerInfo );
void CreateCLReqServerListMes ( const CHostAddress& InetAddr );
void CreateAndImmSendDisconnectionMes(); void CreateCLSendEmptyMesMes ( const CHostAddress& InetAddr,
void CreateAndImmSendAcknMess ( const int& iID, const CHostAddress& TargetInetAddr );
const int& iCnt ); void CreateCLEmptyMes ( const CHostAddress& InetAddr );
bool ParseMessage ( const CVector<uint8_t>& vecbyData, void CreateAndImmSendDisconnectionMes();
const int iNumBytes ); void CreateAndImmSendAcknMess ( const int& iID,
const int& iCnt );
bool ParseConnectionLessMessage ( const CVector<uint8_t>& vecbyData,
const int iNumBytes, bool ParseMessage ( const CVector<uint8_t>& vecbyData,
const CHostAddress& InetAddr ); const int iNumBytes );
bool IsProtocolMessage ( const CVector<uint8_t>& vecbyData, bool ParseConnectionLessMessage ( const CVector<uint8_t>& vecbyData,
const int iNumBytes ); const int iNumBytes,
const CHostAddress& InetAddr );
protected:
class CSendMessage bool IsProtocolMessage ( const CVector<uint8_t>& vecbyData,
{ const int iNumBytes );
public:
CSendMessage() : vecMessage ( 0 ), iID ( PROTMESSID_ILLEGAL ), protected:
iCnt ( 0 ) {} class CSendMessage
CSendMessage ( const CVector<uint8_t>& nMess, const int iNCnt, {
const int iNID ) : vecMessage ( nMess ), iID ( iNID ), public:
iCnt ( iNCnt ) {} CSendMessage() : vecMessage ( 0 ), iID ( PROTMESSID_ILLEGAL ),
iCnt ( 0 ) {}
CSendMessage& operator= ( const CSendMessage& NewSendMess ) CSendMessage ( const CVector<uint8_t>& nMess, const int iNCnt,
{ const int iNID ) : vecMessage ( nMess ), iID ( iNID ),
vecMessage.Init ( NewSendMess.vecMessage.Size() ); iCnt ( iNCnt ) {}
vecMessage = NewSendMess.vecMessage;
CSendMessage& operator= ( const CSendMessage& NewSendMess )
iID = NewSendMess.iID; {
iCnt = NewSendMess.iCnt; vecMessage.Init ( NewSendMess.vecMessage.Size() );
return *this; vecMessage = NewSendMess.vecMessage;
}
iID = NewSendMess.iID;
CVector<uint8_t> vecMessage; iCnt = NewSendMess.iCnt;
int iID, iCnt; return *this;
}; }
void EnqueueMessage ( CVector<uint8_t>& vecMessage, CVector<uint8_t> vecMessage;
const int iCnt, int iID, iCnt;
const int iID ); };
bool ParseMessageFrame ( const CVector<uint8_t>& vecIn, void EnqueueMessage ( CVector<uint8_t>& vecMessage,
const int iNumBytesIn, const int iCnt,
int& iCnt, const int iID );
int& iID,
CVector<uint8_t>& vecData ); bool ParseMessageFrame ( const CVector<uint8_t>& vecIn,
const int iNumBytesIn,
void GenMessageFrame ( CVector<uint8_t>& vecOut, int& iCnt,
const int iCnt, int& iID,
const int iID, CVector<uint8_t>& vecData );
const CVector<uint8_t>& vecData );
void GenMessageFrame ( CVector<uint8_t>& vecOut,
void PutValOnStream ( CVector<uint8_t>& vecIn, const int iCnt,
int& iPos, const int iID,
const uint32_t iVal, const CVector<uint8_t>& vecData );
const int iNumOfBytes );
void PutValOnStream ( CVector<uint8_t>& vecIn,
void PutStringOnStream ( CVector<uint8_t>& vecIn, int& iPos,
int& iPos, const uint32_t iVal,
const QString& sString ); const int iNumOfBytes );
uint32_t GetValFromStream ( const CVector<uint8_t>& vecIn, void PutStringOnStream ( CVector<uint8_t>& vecIn,
int& iPos, int& iPos,
const int iNumOfBytes ); const QString& sString );
bool GetStringFromStream ( const CVector<uint8_t>& vecIn, uint32_t GetValFromStream ( const CVector<uint8_t>& vecIn,
int& iPos, int& iPos,
const int iMaxStringLen, const int iNumOfBytes );
QString& strOut );
bool GetStringFromStream ( const CVector<uint8_t>& vecIn,
bool IsConnectionLessMessageID ( const int iID ) const int& iPos,
{ return (iID >= 1000) & (iID < 2000); } const int iMaxStringLen,
QString& strOut );
void SendMessage();
bool IsConnectionLessMessageID ( const int iID ) const
void CreateAndSendMessage ( const int iID, { return (iID >= 1000) & (iID < 2000); }
const CVector<uint8_t>& vecData );
void SendMessage();
void CreateAndImmSendConLessMessage ( const int iID,
const CVector<uint8_t>& vecData, void CreateAndSendMessage ( const int iID,
const CHostAddress& InetAddr ); const CVector<uint8_t>& vecData );
bool EvaluateJitBufMes ( const CVector<uint8_t>& vecData ); void CreateAndImmSendConLessMessage ( const int iID,
bool EvaluateReqJitBufMes(); const CVector<uint8_t>& vecData,
bool EvaluateChanGainMes ( const CVector<uint8_t>& vecData ); const CHostAddress& InetAddr );
bool EvaluateConClientListMes ( const CVector<uint8_t>& vecData );
bool EvaluateReqConnClientsList(); bool EvaluateJitBufMes ( const CVector<uint8_t>& vecData );
bool EvaluateChanNameMes ( const CVector<uint8_t>& vecData ); bool EvaluateReqJitBufMes();
bool EvaluateReqChanNameMes(); bool EvaluateChanGainMes ( const CVector<uint8_t>& vecData );
bool EvaluateChatTextMes ( const CVector<uint8_t>& vecData ); bool EvaluateConClientListMes ( const CVector<uint8_t>& vecData );
bool EvaluatePingMes ( const CVector<uint8_t>& vecData ); bool EvaluateReqConnClientsList();
bool EvaluateNetwTranspPropsMes ( const CVector<uint8_t>& vecData ); bool EvaluateChanNameMes ( const CVector<uint8_t>& vecData );
bool EvaluateReqNetwTranspPropsMes(); bool EvaluateReqChanNameMes();
bool EvaluateDisconnectionMes(); bool EvaluateChatTextMes ( const CVector<uint8_t>& vecData );
bool EvaluatePingMes ( const CVector<uint8_t>& vecData );
bool EvaluateCLPingMes ( const CHostAddress& InetAddr, bool EvaluateNetwTranspPropsMes ( const CVector<uint8_t>& vecData );
const CVector<uint8_t>& vecData ); bool EvaluateReqNetwTranspPropsMes();
bool EvaluateCLServerFullMes(); bool EvaluateDisconnectionMes();
bool EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData ); bool EvaluateCLPingMes ( const CHostAddress& InetAddr,
bool EvaluateCLServerListMes ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData );
const CVector<uint8_t>& vecData ); bool EvaluateCLPingWithNumClientsMes ( const CHostAddress& InetAddr,
bool EvaluateCLReqServerListMes ( const CHostAddress& InetAddr ); const CVector<uint8_t>& vecData );
bool EvaluateCLSendEmptyMesMes ( const CVector<uint8_t>& vecData ); bool EvaluateCLServerFullMes();
bool EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
int iOldRecID; const CVector<uint8_t>& vecData );
int iOldRecCnt; bool EvaluateCLServerListMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData );
// these two objects must be sequred by a mutex bool EvaluateCLReqServerListMes ( const CHostAddress& InetAddr );
uint8_t iCounter; bool EvaluateCLSendEmptyMesMes ( const CVector<uint8_t>& vecData );
std::list<CSendMessage> SendMessQueue;
int iOldRecID;
QTimer TimerSendMess; int iOldRecCnt;
QMutex Mutex;
// these two objects must be sequred by a mutex
public slots: uint8_t iCounter;
void OnTimerSendMess() { SendMessage(); } std::list<CSendMessage> SendMessQueue;
signals: QTimer TimerSendMess;
// transmitting QMutex Mutex;
void MessReadyForSending ( CVector<uint8_t> vecMessage );
void CLMessReadyForSending ( CHostAddress InetAddr, public slots:
CVector<uint8_t> vecMessage ); void OnTimerSendMess() { SendMessage(); }
// receiving signals:
void ChangeJittBufSize ( int iNewJitBufSize ); // transmitting
void ReqJittBufSize(); void MessReadyForSending ( CVector<uint8_t> vecMessage );
void ChangeNetwBlSiFact ( int iNewNetwBlSiFact ); void CLMessReadyForSending ( CHostAddress InetAddr,
void ChangeChanGain ( int iChanID, double dNewGain ); CVector<uint8_t> vecMessage );
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ServerFullMesReceived(); // receiving
void ReqConnClientsList(); void ChangeJittBufSize ( int iNewJitBufSize );
void ChangeChanName ( QString strName ); void ReqJittBufSize();
void ReqChanName(); void ChangeNetwBlSiFact ( int iNewNetwBlSiFact );
void ChatTextReceived ( QString strChatText ); void ChangeChanGain ( int iChanID, double dNewGain );
void PingReceived ( int iMs ); void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void NetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps ); void ServerFullMesReceived();
void ReqNetTranspProps(); void ReqConnClientsList();
void Disconnection(); void ChangeChanName ( QString strName );
void ReqChanName();
void CLPingReceived ( CHostAddress InetAddr, int iMs ); void ChatTextReceived ( QString strChatText );
void CLRegisterServerReceived ( CHostAddress InetAddr, void PingReceived ( int iMs );
CServerCoreInfo ServerInfo ); void NetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps );
void CLServerListReceived ( CHostAddress InetAddr, void ReqNetTranspProps();
CVector<CServerInfo> vecServerInfo ); void Disconnection();
void CLReqServerList ( CHostAddress InetAddr );
void CLSendEmptyMes ( CHostAddress TargetInetAddr ); void CLPingReceived ( CHostAddress InetAddr, int iMs );
}; void CLPingWithNumClientsReceived ( CHostAddress InetAddr,
int iMs,
#endif /* !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) */ int iNumClients );
void CLRegisterServerReceived ( CHostAddress InetAddr,
CServerCoreInfo ServerInfo );
void CLServerListReceived ( CHostAddress InetAddr,
CVector<CServerInfo> vecServerInfo );
void CLReqServerList ( CHostAddress InetAddr );
void CLSendEmptyMes ( CHostAddress TargetInetAddr );
};
#endif /* !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) */

View File

@ -870,6 +870,23 @@ int CServer::GetFreeChan()
return INVALID_CHANNEL_ID; return INVALID_CHANNEL_ID;
} }
int CServer::GetNumberOfConnectedClients()
{
int iNumConnClients = 0;
// check all possible channels for connection status
for ( int i = 0; i < USED_NUM_CHANNELS; i++ )
{
if ( vecChannels[i].IsConnected() )
{
// this channel is connected, increment counter
iNumConnClients += 1;
}
}
return iNumConnClients;
}
int CServer::CheckAddr ( const CHostAddress& Addr ) int CServer::CheckAddr ( const CHostAddress& Addr )
{ {
CHostAddress InetAddr; CHostAddress InetAddr;

View File

@ -1,297 +1,302 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2011 * Copyright (c) 2004-2011
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
* *
****************************************************************************** ******************************************************************************
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later * Foundation; either version 2 of the License, or (at your option) any later
* version. * version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., * this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
\******************************************************************************/ \******************************************************************************/
#if !defined ( SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ ) #if !defined ( SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ )
#define SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ #define SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_
#include <qobject.h> #include <qobject.h>
#include <qtimer.h> #include <qtimer.h>
#include <qdatetime.h> #include <qdatetime.h>
#include <qhostaddress.h> #include <qhostaddress.h>
#include "celt.h" #include "celt.h"
#include "global.h" #include "global.h"
#include "socket.h" #include "socket.h"
#include "channel.h" #include "channel.h"
#include "util.h" #include "util.h"
#include "serverlogging.h" #include "serverlogging.h"
#include "serverlist.h" #include "serverlist.h"
/* Definitions ****************************************************************/ /* Definitions ****************************************************************/
// no valid channel number // no valid channel number
#define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 ) #define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 )
// minimum timer precision // minimum timer precision
#define MIN_TIMER_RESOLUTION_MS 1 // ms #define MIN_TIMER_RESOLUTION_MS 1 // ms
/* Classes ********************************************************************/ /* Classes ********************************************************************/
#if defined ( __APPLE__ ) || defined ( __MACOSX ) #if defined ( __APPLE__ ) || defined ( __MACOSX )
// using mach timers for Mac // using mach timers for Mac
class CHighPrecisionTimer : public QThread class CHighPrecisionTimer : public QThread
{ {
Q_OBJECT Q_OBJECT
public: public:
CHighPrecisionTimer(); CHighPrecisionTimer();
void Start(); void Start();
void Stop(); void Stop();
bool isActive() { return bRun; } bool isActive() { return bRun; }
protected: protected:
virtual void run(); virtual void run();
bool bRun; bool bRun;
uint64_t iMachDelay; uint64_t iMachDelay;
uint64_t iNextEnd; uint64_t iNextEnd;
signals: signals:
void timeout(); void timeout();
}; };
#else #else
// using QTimer for Windows and Linux // using QTimer for Windows and Linux
class CHighPrecisionTimer : public QObject class CHighPrecisionTimer : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
CHighPrecisionTimer(); CHighPrecisionTimer();
void Start(); void Start();
void Stop(); void Stop();
bool isActive() const { return Timer.isActive(); } bool isActive() const { return Timer.isActive(); }
protected: protected:
QTimer Timer; QTimer Timer;
CVector<int> veciTimeOutIntervals; CVector<int> veciTimeOutIntervals;
int iCurPosInVector; int iCurPosInVector;
int iIntervalCounter; int iIntervalCounter;
public slots: public slots:
void OnTimer(); void OnTimer();
signals: signals:
void timeout(); void timeout();
}; };
#endif #endif
class CServer : public QObject class CServer : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
CServer ( const QString& strLoggingFileName, CServer ( const QString& strLoggingFileName,
const quint16 iPortNumber, const quint16 iPortNumber,
const QString& strHTMLStatusFileName, const QString& strHTMLStatusFileName,
const QString& strHistoryFileName, const QString& strHistoryFileName,
const QString& strServerNameForHTMLStatusFile, const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer ); const QString& strCentralServer );
void Start(); void Start();
void Stop(); void Stop();
bool IsRunning() { return HighPrecisionTimer.isActive(); } bool IsRunning() { return HighPrecisionTimer.isActive(); }
bool GetTimingStdDev ( double& dCurTiStdDev ); bool GetTimingStdDev ( double& dCurTiStdDev );
bool PutData ( const CVector<uint8_t>& vecbyRecBuf, bool PutData ( const CVector<uint8_t>& vecbyRecBuf,
const int iNumBytesRead, const int iNumBytesRead,
const CHostAddress& HostAdr ); const CHostAddress& HostAdr );
void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses, void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
CVector<QString>& vecsName, CVector<QString>& vecsName,
CVector<int>& veciJitBufNumFrames, CVector<int>& veciJitBufNumFrames,
CVector<int>& veciNetwFrameSizeFact ); CVector<int>& veciNetwFrameSizeFact );
protected: protected:
// access functions for actual channels // access functions for actual channels
bool IsConnected ( const int iChanNum ) bool IsConnected ( const int iChanNum )
{ return vecChannels[iChanNum].IsConnected(); } { return vecChannels[iChanNum].IsConnected(); }
void StartStatusHTMLFileWriting ( const QString& strNewFileName, void StartStatusHTMLFileWriting ( const QString& strNewFileName,
const QString& strNewServerNameWithPort ); const QString& strNewServerNameWithPort );
int CheckAddr ( const CHostAddress& Addr ); int CheckAddr ( const CHostAddress& Addr );
int GetFreeChan(); int GetFreeChan();
CVector<CChannelShortInfo> CreateChannelList(); int GetNumberOfConnectedClients();
void CreateAndSendChanListForAllConChannels(); CVector<CChannelShortInfo> CreateChannelList();
void CreateAndSendChanListForThisChan ( const int iCurChanID ); void CreateAndSendChanListForAllConChannels();
void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, void CreateAndSendChanListForThisChan ( const int iCurChanID );
const QString& strChatText ); void CreateAndSendChatTextForAllConChannels ( const int iCurChanID,
void WriteHTMLChannelList(); const QString& strChatText );
void WriteHTMLChannelList();
CVector<int16_t> ProcessData ( const int iCurIndex,
CVector<CVector<int16_t> >& vecvecsData, CVector<int16_t> ProcessData ( const int iCurIndex,
CVector<double>& vecdGains, CVector<CVector<int16_t> >& vecvecsData,
CVector<int>& vecNumAudioChannels ); CVector<double>& vecdGains,
CVector<int>& vecNumAudioChannels );
virtual void customEvent ( QEvent* Event );
virtual void customEvent ( QEvent* Event );
// do not use the vector class since CChannel does not have appropriate
// copy constructor/operator // do not use the vector class since CChannel does not have appropriate
CChannel vecChannels[MAX_NUM_CHANNELS]; // copy constructor/operator
CProtocol ConnLessProtocol; CChannel vecChannels[MAX_NUM_CHANNELS];
QMutex Mutex; CProtocol ConnLessProtocol;
QMutex Mutex;
// audio encoder/decoder
CELTMode* CeltModeMono[MAX_NUM_CHANNELS]; // audio encoder/decoder
CELTEncoder* CeltEncoderMono[MAX_NUM_CHANNELS]; CELTMode* CeltModeMono[MAX_NUM_CHANNELS];
CELTDecoder* CeltDecoderMono[MAX_NUM_CHANNELS]; CELTEncoder* CeltEncoderMono[MAX_NUM_CHANNELS];
CELTMode* CeltModeStereo[MAX_NUM_CHANNELS]; CELTDecoder* CeltDecoderMono[MAX_NUM_CHANNELS];
CELTEncoder* CeltEncoderStereo[MAX_NUM_CHANNELS]; CELTMode* CeltModeStereo[MAX_NUM_CHANNELS];
CELTDecoder* CeltDecoderStereo[MAX_NUM_CHANNELS]; CELTEncoder* CeltEncoderStereo[MAX_NUM_CHANNELS];
CELTDecoder* CeltDecoderStereo[MAX_NUM_CHANNELS];
CVector<QString> vstrChatColors;
CVector<QString> vstrChatColors;
// actual working objects
CSocket Socket; // actual working objects
CCycleTimeVariance CycleTimeVariance; CSocket Socket;
CCycleTimeVariance CycleTimeVariance;
// logging
CServerLogging Logging; // logging
CServerLogging Logging;
// HTML file server status
bool bWriteStatusHTMLFile; // HTML file server status
QString strServerHTMLFileListName; bool bWriteStatusHTMLFile;
QString strServerNameWithPort; QString strServerHTMLFileListName;
QString strServerNameWithPort;
CHighPrecisionTimer HighPrecisionTimer;
CVector<short> vecsSendData; CHighPrecisionTimer HighPrecisionTimer;
CVector<short> vecsSendData;
// server list
CServerListManager ServerListManager; // server list
CServerListManager ServerListManager;
public slots:
void OnTimer(); public slots:
void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage ); void OnTimer();
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage ); void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage );
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnCLPingReceived ( CHostAddress InetAddr, int iMs )
{ ConnLessProtocol.CreateCLPingMes ( InetAddr, iMs ); } void OnCLPingReceived ( CHostAddress InetAddr, int iMs )
{
void OnCLSendEmptyMes ( CHostAddress TargetInetAddr ) ConnLessProtocol.CreateCLPingWithNumClientsMes ( InetAddr,
{ iMs,
// only send empty message if server list is enabled and this is not GetNumberOfConnectedClients() );
// the central server }
if ( ServerListManager.GetEnabled() &&
!ServerListManager.GetIsCentralServer() ) void OnCLSendEmptyMes ( CHostAddress TargetInetAddr )
{ {
ConnLessProtocol.CreateCLEmptyMes ( TargetInetAddr ); // only send empty message if server list is enabled and this is not
} // the central server
} if ( ServerListManager.GetEnabled() &&
!ServerListManager.GetIsCentralServer() )
void OnCLReqServerList ( CHostAddress InetAddr ) {
{ ServerListManager.QueryServerList ( InetAddr ); } ConnLessProtocol.CreateCLEmptyMes ( TargetInetAddr );
}
void OnCLRegisterServerReceived ( CHostAddress InetAddr, }
CServerCoreInfo ServerInfo )
{ void OnCLReqServerList ( CHostAddress InetAddr )
ServerListManager.RegisterServer ( InetAddr, ServerInfo ); { ServerListManager.QueryServerList ( InetAddr ); }
}
void OnCLRegisterServerReceived ( CHostAddress InetAddr,
CServerCoreInfo ServerInfo )
// CODE TAG: MAX_NUM_CHANNELS_TAG {
// make sure we have MAX_NUM_CHANNELS connections!!! ServerListManager.RegisterServer ( InetAddr, ServerInfo );
// send message }
void OnSendProtMessCh0 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 0, mess ); }
void OnSendProtMessCh1 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 1, mess ); }
void OnSendProtMessCh2 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 2, mess ); } // CODE TAG: MAX_NUM_CHANNELS_TAG
void OnSendProtMessCh3 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 3, mess ); } // make sure we have MAX_NUM_CHANNELS connections!!!
void OnSendProtMessCh4 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 4, mess ); } // send message
void OnSendProtMessCh5 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 5, mess ); } void OnSendProtMessCh0 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 0, mess ); }
void OnSendProtMessCh6 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 6, mess ); } void OnSendProtMessCh1 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 1, mess ); }
void OnSendProtMessCh7 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 7, mess ); } void OnSendProtMessCh2 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 2, mess ); }
void OnSendProtMessCh8 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 8, mess ); } void OnSendProtMessCh3 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 3, mess ); }
void OnSendProtMessCh9 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 9, mess ); } void OnSendProtMessCh4 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 4, mess ); }
void OnSendProtMessCh10 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 10, mess ); } void OnSendProtMessCh5 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 5, mess ); }
void OnSendProtMessCh11 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 11, mess ); } void OnSendProtMessCh6 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 6, mess ); }
void OnSendProtMessCh7 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 7, mess ); }
void OnNewConnectionCh0() { vecChannels[0].CreateReqJitBufMes(); } void OnSendProtMessCh8 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 8, mess ); }
void OnNewConnectionCh1() { vecChannels[1].CreateReqJitBufMes(); } void OnSendProtMessCh9 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 9, mess ); }
void OnNewConnectionCh2() { vecChannels[2].CreateReqJitBufMes(); } void OnSendProtMessCh10 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 10, mess ); }
void OnNewConnectionCh3() { vecChannels[3].CreateReqJitBufMes(); } void OnSendProtMessCh11 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 11, mess ); }
void OnNewConnectionCh4() { vecChannels[4].CreateReqJitBufMes(); }
void OnNewConnectionCh5() { vecChannels[5].CreateReqJitBufMes(); } void OnNewConnectionCh0() { vecChannels[0].CreateReqJitBufMes(); }
void OnNewConnectionCh6() { vecChannels[6].CreateReqJitBufMes(); } void OnNewConnectionCh1() { vecChannels[1].CreateReqJitBufMes(); }
void OnNewConnectionCh7() { vecChannels[7].CreateReqJitBufMes(); } void OnNewConnectionCh2() { vecChannels[2].CreateReqJitBufMes(); }
void OnNewConnectionCh8() { vecChannels[8].CreateReqJitBufMes(); } void OnNewConnectionCh3() { vecChannels[3].CreateReqJitBufMes(); }
void OnNewConnectionCh9() { vecChannels[9].CreateReqJitBufMes(); } void OnNewConnectionCh4() { vecChannels[4].CreateReqJitBufMes(); }
void OnNewConnectionCh10() { vecChannels[10].CreateReqJitBufMes(); } void OnNewConnectionCh5() { vecChannels[5].CreateReqJitBufMes(); }
void OnNewConnectionCh11() { vecChannels[11].CreateReqJitBufMes(); } void OnNewConnectionCh6() { vecChannels[6].CreateReqJitBufMes(); }
void OnNewConnectionCh7() { vecChannels[7].CreateReqJitBufMes(); }
void OnReqConnClientsListCh0() { CreateAndSendChanListForThisChan ( 0 ); } void OnNewConnectionCh8() { vecChannels[8].CreateReqJitBufMes(); }
void OnReqConnClientsListCh1() { CreateAndSendChanListForThisChan ( 1 ); } void OnNewConnectionCh9() { vecChannels[9].CreateReqJitBufMes(); }
void OnReqConnClientsListCh2() { CreateAndSendChanListForThisChan ( 2 ); } void OnNewConnectionCh10() { vecChannels[10].CreateReqJitBufMes(); }
void OnReqConnClientsListCh3() { CreateAndSendChanListForThisChan ( 3 ); } void OnNewConnectionCh11() { vecChannels[11].CreateReqJitBufMes(); }
void OnReqConnClientsListCh4() { CreateAndSendChanListForThisChan ( 4 ); }
void OnReqConnClientsListCh5() { CreateAndSendChanListForThisChan ( 5 ); } void OnReqConnClientsListCh0() { CreateAndSendChanListForThisChan ( 0 ); }
void OnReqConnClientsListCh6() { CreateAndSendChanListForThisChan ( 6 ); } void OnReqConnClientsListCh1() { CreateAndSendChanListForThisChan ( 1 ); }
void OnReqConnClientsListCh7() { CreateAndSendChanListForThisChan ( 7 ); } void OnReqConnClientsListCh2() { CreateAndSendChanListForThisChan ( 2 ); }
void OnReqConnClientsListCh8() { CreateAndSendChanListForThisChan ( 8 ); } void OnReqConnClientsListCh3() { CreateAndSendChanListForThisChan ( 3 ); }
void OnReqConnClientsListCh9() { CreateAndSendChanListForThisChan ( 9 ); } void OnReqConnClientsListCh4() { CreateAndSendChanListForThisChan ( 4 ); }
void OnReqConnClientsListCh10() { CreateAndSendChanListForThisChan ( 10 ); } void OnReqConnClientsListCh5() { CreateAndSendChanListForThisChan ( 5 ); }
void OnReqConnClientsListCh11() { CreateAndSendChanListForThisChan ( 11 ); } void OnReqConnClientsListCh6() { CreateAndSendChanListForThisChan ( 6 ); }
void OnReqConnClientsListCh7() { CreateAndSendChanListForThisChan ( 7 ); }
void OnNameHasChangedCh0() { CreateAndSendChanListForAllConChannels(); } void OnReqConnClientsListCh8() { CreateAndSendChanListForThisChan ( 8 ); }
void OnNameHasChangedCh1() { CreateAndSendChanListForAllConChannels(); } void OnReqConnClientsListCh9() { CreateAndSendChanListForThisChan ( 9 ); }
void OnNameHasChangedCh2() { CreateAndSendChanListForAllConChannels(); } void OnReqConnClientsListCh10() { CreateAndSendChanListForThisChan ( 10 ); }
void OnNameHasChangedCh3() { CreateAndSendChanListForAllConChannels(); } void OnReqConnClientsListCh11() { CreateAndSendChanListForThisChan ( 11 ); }
void OnNameHasChangedCh4() { CreateAndSendChanListForAllConChannels(); }
void OnNameHasChangedCh5() { CreateAndSendChanListForAllConChannels(); } void OnNameHasChangedCh0() { CreateAndSendChanListForAllConChannels(); }
void OnNameHasChangedCh6() { CreateAndSendChanListForAllConChannels(); } void OnNameHasChangedCh1() { CreateAndSendChanListForAllConChannels(); }
void OnNameHasChangedCh7() { CreateAndSendChanListForAllConChannels(); } void OnNameHasChangedCh2() { CreateAndSendChanListForAllConChannels(); }
void OnNameHasChangedCh8() { CreateAndSendChanListForAllConChannels(); } void OnNameHasChangedCh3() { CreateAndSendChanListForAllConChannels(); }
void OnNameHasChangedCh9() { CreateAndSendChanListForAllConChannels(); } void OnNameHasChangedCh4() { CreateAndSendChanListForAllConChannels(); }
void OnNameHasChangedCh10() { CreateAndSendChanListForAllConChannels(); } void OnNameHasChangedCh5() { CreateAndSendChanListForAllConChannels(); }
void OnNameHasChangedCh11() { CreateAndSendChanListForAllConChannels(); } void OnNameHasChangedCh6() { CreateAndSendChanListForAllConChannels(); }
void OnNameHasChangedCh7() { CreateAndSendChanListForAllConChannels(); }
void OnChatTextReceivedCh0 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 0, strChatText ); } void OnNameHasChangedCh8() { CreateAndSendChanListForAllConChannels(); }
void OnChatTextReceivedCh1 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 1, strChatText ); } void OnNameHasChangedCh9() { CreateAndSendChanListForAllConChannels(); }
void OnChatTextReceivedCh2 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 2, strChatText ); } void OnNameHasChangedCh10() { CreateAndSendChanListForAllConChannels(); }
void OnChatTextReceivedCh3 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 3, strChatText ); } void OnNameHasChangedCh11() { CreateAndSendChanListForAllConChannels(); }
void OnChatTextReceivedCh4 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 4, strChatText ); }
void OnChatTextReceivedCh5 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 5, strChatText ); } void OnChatTextReceivedCh0 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 0, strChatText ); }
void OnChatTextReceivedCh6 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 6, strChatText ); } void OnChatTextReceivedCh1 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 1, strChatText ); }
void OnChatTextReceivedCh7 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 7, strChatText ); } void OnChatTextReceivedCh2 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 2, strChatText ); }
void OnChatTextReceivedCh8 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 8, strChatText ); } void OnChatTextReceivedCh3 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 3, strChatText ); }
void OnChatTextReceivedCh9 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 9, strChatText ); } void OnChatTextReceivedCh4 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 4, strChatText ); }
void OnChatTextReceivedCh10 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 10, strChatText ); } void OnChatTextReceivedCh5 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 5, strChatText ); }
void OnChatTextReceivedCh11 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 11, strChatText ); } void OnChatTextReceivedCh6 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 6, strChatText ); }
void OnChatTextReceivedCh7 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 7, strChatText ); }
void OnPingReceivedCh0 ( int iMs ) { vecChannels[0].CreatePingMes ( iMs ); } void OnChatTextReceivedCh8 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 8, strChatText ); }
void OnPingReceivedCh1 ( int iMs ) { vecChannels[1].CreatePingMes ( iMs ); } void OnChatTextReceivedCh9 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 9, strChatText ); }
void OnPingReceivedCh2 ( int iMs ) { vecChannels[2].CreatePingMes ( iMs ); } void OnChatTextReceivedCh10 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 10, strChatText ); }
void OnPingReceivedCh3 ( int iMs ) { vecChannels[3].CreatePingMes ( iMs ); } void OnChatTextReceivedCh11 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 11, strChatText ); }
void OnPingReceivedCh4 ( int iMs ) { vecChannels[4].CreatePingMes ( iMs ); }
void OnPingReceivedCh5 ( int iMs ) { vecChannels[5].CreatePingMes ( iMs ); } void OnPingReceivedCh0 ( int iMs ) { vecChannels[0].CreatePingMes ( iMs ); }
void OnPingReceivedCh6 ( int iMs ) { vecChannels[6].CreatePingMes ( iMs ); } void OnPingReceivedCh1 ( int iMs ) { vecChannels[1].CreatePingMes ( iMs ); }
void OnPingReceivedCh7 ( int iMs ) { vecChannels[7].CreatePingMes ( iMs ); } void OnPingReceivedCh2 ( int iMs ) { vecChannels[2].CreatePingMes ( iMs ); }
void OnPingReceivedCh8 ( int iMs ) { vecChannels[8].CreatePingMes ( iMs ); } void OnPingReceivedCh3 ( int iMs ) { vecChannels[3].CreatePingMes ( iMs ); }
void OnPingReceivedCh9 ( int iMs ) { vecChannels[9].CreatePingMes ( iMs ); } void OnPingReceivedCh4 ( int iMs ) { vecChannels[4].CreatePingMes ( iMs ); }
void OnPingReceivedCh10 ( int iMs ) { vecChannels[10].CreatePingMes ( iMs ); } void OnPingReceivedCh5 ( int iMs ) { vecChannels[5].CreatePingMes ( iMs ); }
void OnPingReceivedCh11 ( int iMs ) { vecChannels[11].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 ); }
#endif /* !defined ( SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ ) */ 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_ ) */

View File

@ -62,7 +62,6 @@ ServerList.append ( CServerListEntry (
"", "",
QLocale::Germany, // TEST QLocale::Germany, // TEST
"Munich", // TEST "Munich", // TEST
0, // will be updated later
USED_NUM_CHANNELS, USED_NUM_CHANNELS,
true ) ); // TEST true ) ); // TEST
@ -187,7 +186,6 @@ void CServerListManager::RegisterServer ( const CHostAddress& InetAddr,
ServerList[iSelIdx].strTopic = ServerInfo.strTopic; ServerList[iSelIdx].strTopic = ServerInfo.strTopic;
ServerList[iSelIdx].eCountry = ServerInfo.eCountry; ServerList[iSelIdx].eCountry = ServerInfo.eCountry;
ServerList[iSelIdx].strCity = ServerInfo.strCity; ServerList[iSelIdx].strCity = ServerInfo.strCity;
ServerList[iSelIdx].iNumClients = ServerInfo.iNumClients;
ServerList[iSelIdx].iMaxNumClients = ServerInfo.iMaxNumClients; ServerList[iSelIdx].iMaxNumClients = ServerInfo.iMaxNumClients;
ServerList[iSelIdx].bPermanentOnline = ServerInfo.bPermanentOnline; ServerList[iSelIdx].bPermanentOnline = ServerInfo.bPermanentOnline;
ServerList[iSelIdx].UpdateRegistration(); ServerList[iSelIdx].UpdateRegistration();

View File

@ -1,156 +1,152 @@
/******************************************************************************\ /******************************************************************************\
* Copyright (c) 2004-2011 * Copyright (c) 2004-2011
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
* *
Currently, if you want to run a private server, you have to open the firewall of Currently, if you want to run a private server, you have to open the firewall of
your computer at the correct ports and introduce a port forwarding at your your computer at the correct ports and introduce a port forwarding at your
router to get it work. Using a central server simplifies the process. The user router to get it work. Using a central server simplifies the process. The user
who wants to run a llcon server just registers his server a the central server who wants to run a llcon server just registers his server a the central server
and a mechanism implemented in the protocol opens the firewall similar to STUN. and a mechanism implemented in the protocol opens the firewall similar to STUN.
REQUIREMENTS: REQUIREMENTS:
The client sets the URL of the central llcon server and can get a list of all The client sets the URL of the central llcon server and can get a list of all
currently activated and registered private llcon servers. If the user clicks on currently activated and registered private llcon servers. If the user clicks on
the server of his choice, he gets connected to this server. the server of his choice, he gets connected to this server.
The server list must be available in both cases: if the client is connected to The server list must be available in both cases: if the client is connected to
the central server or not. the central server or not.
The server list contains the name of the server, an optional topic, an optional The server list contains the name of the server, an optional topic, an optional
location, the number of connected users and a ping time which is updated as location, the number of connected users and a ping time which is updated as
long as the server list is visible (similar to the ping measurement in the long as the server list is visible (similar to the ping measurement in the
general settings dialog). Additional information may be also present in the list general settings dialog). Additional information may be also present in the list
like reliability of the server, etc. like reliability of the server, etc.
CONNECTION PROCESS: CONNECTION PROCESS:
The private server contacts the central server and registers through some The private server contacts the central server and registers through some
protocol mechanism. protocol mechanism.
If a client requests the server list from the central server, the central server If a client requests the server list from the central server, the central server
sends the IP address of the client to each registered private servers so that sends the IP address of the client to each registered private servers so that
they can immediately send a "firewall opening" UDP packet to this IP address. they can immediately send a "firewall opening" UDP packet to this IP address.
If the client now sends ping messages to each of the private servers in the If the client now sends ping messages to each of the private servers in the
list, the firewalls and routers are prepared for receiving UDP packets from this list, the firewalls and routers are prepared for receiving UDP packets from this
IP address and will tunnel it through. Note: this mechanism will not work in a IP address and will tunnel it through. Note: this mechanism will not work in a
private network. private network.
****************************************************************************** ******************************************************************************
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later * Foundation; either version 2 of the License, or (at your option) any later
* version. * version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., * this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
\******************************************************************************/ \******************************************************************************/
#if !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) #if !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ )
#define SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ #define SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_
#include <qobject.h> #include <qobject.h>
#include <qlocale.h> #include <qlocale.h>
#include <qlist.h> #include <qlist.h>
#include <qtimer.h> #include <qtimer.h>
#include <qmutex.h> #include <qmutex.h>
#include "global.h" #include "global.h"
#include "util.h" #include "util.h"
#include "protocol.h" #include "protocol.h"
/* Classes ********************************************************************/ /* Classes ********************************************************************/
class CServerListEntry : public CServerInfo class CServerListEntry : public CServerInfo
{ {
public: public:
CServerListEntry() : CServerListEntry() :
CServerInfo ( CHostAddress(), CServerInfo ( CHostAddress(),
"", "",
"", "",
QLocale::AnyCountry, QLocale::AnyCountry,
"", "",
0, 0,
0, false ) { UpdateRegistration(); }
false ) { UpdateRegistration(); }
CServerListEntry ( const CHostAddress& NHAddr,
CServerListEntry ( const CHostAddress& NHAddr, const QString& NsName,
const QString& NsName, const QString& NsTopic,
const QString& NsTopic, const QLocale::Country& NeCountry,
const QLocale::Country& NeCountry, const QString& NsCity,
const QString& NsCity, const int NiMaxNumClients,
const int NiNumClients, const bool NbPermOnline)
const int NiMaxNumClients, : CServerInfo ( NHAddr,
const bool NbPermOnline) NsName,
: CServerInfo ( NHAddr, NsTopic,
NsName, NeCountry,
NsTopic, NsCity,
NeCountry, NiMaxNumClients,
NsCity, NbPermOnline ) { UpdateRegistration(); }
NiNumClients,
NiMaxNumClients, CServerListEntry ( const CHostAddress& NHAddr,
NbPermOnline ) { UpdateRegistration(); } const CServerCoreInfo& NewCoreServerInfo )
: CServerInfo ( NHAddr,
CServerListEntry ( const CHostAddress& NHAddr, NewCoreServerInfo.strName,
const CServerCoreInfo& NewCoreServerInfo ) NewCoreServerInfo.strTopic,
: CServerInfo ( NHAddr, NewCoreServerInfo.eCountry,
NewCoreServerInfo.strName, NewCoreServerInfo.strCity,
NewCoreServerInfo.strTopic, NewCoreServerInfo.iMaxNumClients,
NewCoreServerInfo.eCountry, NewCoreServerInfo.bPermanentOnline )
NewCoreServerInfo.strCity, { UpdateRegistration(); }
NewCoreServerInfo.iNumClients,
NewCoreServerInfo.iMaxNumClients, void UpdateRegistration() { RegisterTime.start(); }
NewCoreServerInfo.bPermanentOnline )
{ UpdateRegistration(); } public:
// time on which the entry was registered
void UpdateRegistration() { RegisterTime.start(); } QTime RegisterTime;
};
public:
// time on which the entry was registered class CServerListManager : public QObject
QTime RegisterTime; {
}; Q_OBJECT
class CServerListManager : public QObject public:
{ CServerListManager ( const QString& sNCentServAddr,
Q_OBJECT CProtocol* pNConLProt );
public: void SetEnabled ( const bool bState );
CServerListManager ( const QString& sNCentServAddr, bool GetEnabled() const { return bEnabled; }
CProtocol* pNConLProt ); bool GetIsCentralServer() const { return bIsCentralServer; }
void SetEnabled ( const bool bState ); void RegisterServer ( const CHostAddress& InetAddr,
bool GetEnabled() const { return bEnabled; } const CServerCoreInfo& ServerInfo );
bool GetIsCentralServer() const { return bIsCentralServer; }
void QueryServerList ( const CHostAddress& InetAddr );
void RegisterServer ( const CHostAddress& InetAddr,
const CServerCoreInfo& ServerInfo ); protected:
QTimer TimerPollList;
void QueryServerList ( const CHostAddress& InetAddr ); QTimer TimerRegistering;
QMutex Mutex;
protected: QList<CServerListEntry> ServerList;
QTimer TimerPollList; QString strCentralServerAddress;
QTimer TimerRegistering; bool bEnabled;
QMutex Mutex; bool bIsCentralServer;
QList<CServerListEntry> ServerList;
QString strCentralServerAddress; CProtocol* pConnLessProtocol;
bool bEnabled;
bool bIsCentralServer; public slots:
void OnTimerPollList();
CProtocol* pConnLessProtocol; void OnTimerRegistering();
};
public slots:
void OnTimerPollList(); #endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */
void OnTimerRegistering();
};
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */

View File

@ -487,7 +487,6 @@ public:
strTopic ( "" ), strTopic ( "" ),
eCountry ( QLocale::AnyCountry ), eCountry ( QLocale::AnyCountry ),
strCity ( "" ), strCity ( "" ),
iNumClients ( 0 ),
iMaxNumClients ( 0 ), iMaxNumClients ( 0 ),
bPermanentOnline ( false ) {} bPermanentOnline ( false ) {}
@ -496,14 +495,12 @@ public:
const QString& NsTopic, const QString& NsTopic,
const QLocale::Country& NeCountry, const QLocale::Country& NeCountry,
const QString& NsCity, const QString& NsCity,
const int NiNumClients,
const int NiMaxNumClients, const int NiMaxNumClients,
const bool NbPermOnline) : const bool NbPermOnline) :
strName ( NsName ), strName ( NsName ),
strTopic ( NsTopic ), strTopic ( NsTopic ),
eCountry ( NeCountry ), eCountry ( NeCountry ),
strCity ( NsCity ), strCity ( NsCity ),
iNumClients ( NiNumClients ),
iMaxNumClients ( NiMaxNumClients ), iMaxNumClients ( NiMaxNumClients ),
bPermanentOnline ( NbPermOnline ) {} bPermanentOnline ( NbPermOnline ) {}
@ -520,9 +517,6 @@ public:
// city in which the server is located // city in which the server is located
QString strCity; QString strCity;
// current number of connected clients
int iNumClients;
// maximum number of clients which can connect to the server at the same // maximum number of clients which can connect to the server at the same
// time // time
int iMaxNumClients; int iMaxNumClients;
@ -540,7 +534,6 @@ public:
QLocale::AnyCountry, QLocale::AnyCountry,
"", "",
0, 0,
0,
false ), HostAddr ( CHostAddress() ) {} false ), HostAddr ( CHostAddress() ) {}
CServerInfo ( CServerInfo (
@ -549,14 +542,12 @@ public:
const QString& NsTopic, const QString& NsTopic,
const QLocale::Country& NeCountry, const QLocale::Country& NeCountry,
const QString& NsCity, const QString& NsCity,
const int NiNumClients,
const int NiMaxNumClients, const int NiMaxNumClients,
const bool NbPermOnline) : const bool NbPermOnline) :
CServerCoreInfo ( NsName, CServerCoreInfo ( NsName,
NsTopic, NsTopic,
NeCountry, NeCountry,
NsCity, NsCity,
NiNumClients,
NiMaxNumClients, NiMaxNumClients,
NbPermOnline ), HostAddr ( NHAddr ) {} NbPermOnline ), HostAddr ( NHAddr ) {}