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> ) ) );
QObject::connect ( &ConnLessProtocol, SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) );
QObject::connect ( &ConnLessProtocol,
SIGNAL ( CLPingWithNumClientsReceived ( CHostAddress, int, int ) ),
this, SLOT ( OnCLPingWithNumClientsReceived ( CHostAddress, int, int ) ) );
QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ),
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)
const int iCurDiff = EvaluatePingMessage ( iMs );
if ( iCurDiff >= 0 )
{
emit CLPingTimeReceived ( InetAddr, iCurDiff );
emit CLPingTimeWithNumClientsReceived ( InetAddr,
iCurDiff,
iNumClients );
}
}

View File

@ -1,325 +1,329 @@
/******************************************************************************\
* Copyright (c) 2004-2011
*
* Author(s):
* Volker Fischer
*
******************************************************************************
*
* 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
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* 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
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* 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.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
#if !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ )
#define CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_
#include <qglobal.h>
#include <qhostaddress.h>
#include <qhostinfo.h>
#include <qstring.h>
#include <qdatetime.h>
#include <qmessagebox.h>
#include "celt.h"
#include "global.h"
#include "socket.h"
#include "channel.h"
#include "util.h"
#include "buffer.h"
#ifdef LLCON_VST_PLUGIN
# include "vstsound.h"
#else
# ifdef _WIN32
# include "../windows/sound.h"
# else
# if defined ( __APPLE__ ) || defined ( __MACOSX )
# include "../mac/sound.h"
# else
# include "../linux/sound.h"
# include <sched.h>
# include <socket.h>
# include <netdb.h>
# endif
# endif
#endif
/* Definitions ****************************************************************/
// audio in fader range
#define AUD_FADER_IN_MIN 0
#define AUD_FADER_IN_MAX 100
#define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 )
// audio reverberation range
#define AUD_REVERB_MAX 100
// CELT number of coded bytes per audio packet
// 24: mono low/normal quality 156 kbsp (128) / 114 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_HIGH_QUALITY 44
// 46: stereo low/normal quality 222 kbsp (128) / 180 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_HIGH_QUALITY 70
/* Classes ********************************************************************/
class CClient : public QObject
{
Q_OBJECT
public:
CClient ( const quint16 iPortNumber );
void Start();
void Stop();
bool IsRunning() { return Sound.IsRunning(); }
bool SetServerAddr ( QString strNAddr );
double MicLevelL() { return SignalLevelMeter.MicLevelLeft(); }
double MicLevelR() { return SignalLevelMeter.MicLevelRight(); }
bool IsConnected() { return Channel.IsConnected(); }
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
bool GetOpenChatOnNewMessage() const { return bOpenChatOnNewMessage; }
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
EGUIDesign GetGUIDesign() const { return eGUIDesign; }
void SetGUIDesign ( const EGUIDesign bNGD ) { eGUIDesign = bNGD; }
bool GetCELTHighQuality() const { return bCeltDoHighQuality; }
void SetCELTHighQuality ( const bool bNCeltHighQualityFlag );
bool GetUseStereo() const { return bUseStereo; }
void SetUseStereo ( const bool bNUseStereo );
int GetAudioInFader() const { return iAudioInFader; }
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
int GetReverbLevel() const { return iReverbLevel; }
void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; }
bool IsReverbOnLeftChan() const { return bReverbOnLeftChan; }
void SetReverbOnLeftChan ( const bool bIL )
{
bReverbOnLeftChan = bIL;
AudioReverbL.Clear();
AudioReverbR.Clear();
}
void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; }
bool GetDoAutoSockBufSize() const { return bDoAutoSockBufSize; }
void SetSockBufNumFrames ( const int iNumBlocks )
{
// only change parameter if new parameter is different from current one
if ( Channel.GetSockBufNumFrames() != iNumBlocks )
{
// set the new socket size (number of frames)
if ( !Channel.SetSockBufNumFrames ( iNumBlocks ) )
{
// if setting of socket buffer size was successful,
// tell the server that size has changed
Channel.CreateJitBufMes ( iNumBlocks );
}
}
}
int GetSockBufNumFrames() { return Channel.GetSockBufNumFrames(); }
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
// sound card device selection
int GetSndCrdNumDev() { return Sound.GetNumDev(); }
QString GetSndCrdDeviceName ( const int iDiD )
{ return Sound.GetDeviceName ( iDiD ); }
QString SetSndCrdDev ( const int iNewDev );
int GetSndCrdDev() { return Sound.GetDev(); }
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
// sound card channel selection
int GetSndCrdNumInputChannels() { return Sound.GetNumInputChannels(); }
QString GetSndCrdInputChannelName ( const int iDiD ) { return Sound.GetInputChannelName ( iDiD ); }
void SetSndCrdLeftInputChannel ( const int iNewChan );
void SetSndCrdRightInputChannel ( const int iNewChan );
int GetSndCrdLeftInputChannel() { return Sound.GetLeftInputChannel(); }
int GetSndCrdRightInputChannel() { return Sound.GetRightInputChannel(); }
int GetSndCrdNumOutputChannels() { return Sound.GetNumOutputChannels(); }
QString GetSndCrdOutputChannelName ( const int iDiD ) { return Sound.GetOutputChannelName ( iDiD ); }
void SetSndCrdLeftOutputChannel ( const int iNewChan );
void SetSndCrdRightOutputChannel ( const int iNewChan );
int GetSndCrdLeftOutputChannel() { return Sound.GetLeftOutputChannel(); }
int GetSndCrdRightOutputChannel() { return Sound.GetRightOutputChannel(); }
void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor );
int GetSndCrdPrefFrameSizeFactor()
{ return iSndCrdPrefFrameSizeFactor; }
int GetSndCrdActualMonoBlSize()
{
// the actual sound card mono block size depends on whether a
// sound card conversion buffer is used or not
if ( bSndCrdConversionBufferRequired )
{
return iSndCardMonoBlockSizeSamConvBuff;
}
else
{
return iMonoBlockSizeSam;
}
}
int GetSystemMonoBlSize() { return iMonoBlockSizeSam; }
int GetSndCrdConvBufAdditionalDelayMonoBlSize()
{
if ( bSndCrdConversionBufferRequired )
{
// by introducing the conversion buffer we also introduce additional
// delay which equals the "internal" mono buffer size
return iMonoBlockSizeSam;
}
else
{
return 0;
}
}
bool GetFraSiFactPrefSupported() { return bFraSiFactPrefSupported; }
bool GetFraSiFactDefSupported() { return bFraSiFactDefSupported; }
bool GetFraSiFactSafeSupported() { return bFraSiFactSafeSupported; }
void SetRemoteChanGain ( const int iId, const double dGain )
{ Channel.SetRemoteChanGain ( iId, dGain ); }
void SetRemoteName() { Channel.SetRemoteName ( strName ); }
void CreateChatTextMes ( const QString& strChatText )
{ Channel.CreateChatTextMes ( strChatText ); }
void CreatePingMes()
{ Channel.CreatePingMes ( PreparePingMessage() ); }
void CreateCLPingMes ( const CHostAddress& InetAddr )
{ ConnLessProtocol.CreateCLPingMes ( InetAddr, PreparePingMessage() ); }
void CreateCLReqServerListMes ( const CHostAddress& InetAddr )
{ ConnLessProtocol.CreateCLReqServerListMes ( InetAddr ); }
int EstimatedOverallDelay ( const int iPingTimeMs );
CChannel* GetChannel() { return &Channel; }
// settings
CVector<QString> vstrIPAddress;
QString strName;
#ifdef LLCON_VST_PLUGIN
// VST version must have direct access to sound object
CSound* GetSound() { return &Sound; }
#endif
protected:
// callback function must be static, otherwise it does not work
static void AudioCallback ( CVector<short>& psData, void* arg );
void Init();
void ProcessSndCrdAudioData ( CVector<short>& vecsStereoSndCrd );
void ProcessAudioDataIntern ( CVector<short>& vecsStereoSndCrd );
void UpdateSocketBufferSize();
int PreparePingMessage();
int EvaluatePingMessage ( const int iMs );
// only one channel is needed for client application
CChannel Channel;
CProtocol ConnLessProtocol;
bool bDoAutoSockBufSize;
// audio encoder/decoder
CELTMode* CeltModeMono;
CELTEncoder* CeltEncoderMono;
CELTDecoder* CeltDecoderMono;
CELTMode* CeltModeStereo;
CELTEncoder* CeltEncoderStereo;
CELTDecoder* CeltDecoderStereo;
int iCeltNumCodedBytes;
bool bCeltDoHighQuality;
bool bUseStereo;
CVector<unsigned char> vecCeltData;
CSocket Socket;
CSound Sound;
CStereoSignalLevelMeter SignalLevelMeter;
CVector<uint8_t> vecbyNetwData;
int iAudioInFader;
bool bReverbOnLeftChan;
int iReverbLevel;
CAudioReverb AudioReverbL;
CAudioReverb AudioReverbR;
int iSndCrdPrefFrameSizeFactor;
int iSndCrdFrameSizeFactor;
bool bSndCrdConversionBufferRequired;
int iSndCardMonoBlockSizeSamConvBuff;
CBufferBase<int16_t> SndCrdConversionBufferIn;
CBufferBase<int16_t> SndCrdConversionBufferOut;
CVector<int16_t> vecDataConvBuf;
bool bFraSiFactPrefSupported;
bool bFraSiFactDefSupported;
bool bFraSiFactSafeSupported;
int iMonoBlockSizeSam;
int iStereoBlockSizeSam;
bool bOpenChatOnNewMessage;
EGUIDesign eGUIDesign;
CVector<int16_t> vecsAudioSndCrdMono;
CVector<double> vecdAudioStereo;
CVector<int16_t> vecsNetwork;
// for ping measurement
CPreciseTime PreciseTime;
CCycleTimeVariance CycleTimeVariance;
public slots:
void OnSendProtMessage ( 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 CLServerListReceived ( CHostAddress InetAddr,
CVector<CServerInfo> vecServerInfo );
void CLPingTimeReceived ( CHostAddress InetAddr, int iPingTime );
void Disconnected();
void Stopped();
};
#endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */
/******************************************************************************\
* Copyright (c) 2004-2011
*
* Author(s):
* Volker Fischer
*
******************************************************************************
*
* 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
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* 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
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* 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.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
#if !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ )
#define CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_
#include <qglobal.h>
#include <qhostaddress.h>
#include <qhostinfo.h>
#include <qstring.h>
#include <qdatetime.h>
#include <qmessagebox.h>
#include "celt.h"
#include "global.h"
#include "socket.h"
#include "channel.h"
#include "util.h"
#include "buffer.h"
#ifdef LLCON_VST_PLUGIN
# include "vstsound.h"
#else
# ifdef _WIN32
# include "../windows/sound.h"
# else
# if defined ( __APPLE__ ) || defined ( __MACOSX )
# include "../mac/sound.h"
# else
# include "../linux/sound.h"
# include <sched.h>
# include <socket.h>
# include <netdb.h>
# endif
# endif
#endif
/* Definitions ****************************************************************/
// audio in fader range
#define AUD_FADER_IN_MIN 0
#define AUD_FADER_IN_MAX 100
#define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 )
// audio reverberation range
#define AUD_REVERB_MAX 100
// CELT number of coded bytes per audio packet
// 24: mono low/normal quality 156 kbsp (128) / 114 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_HIGH_QUALITY 44
// 46: stereo low/normal quality 222 kbsp (128) / 180 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_HIGH_QUALITY 70
/* Classes ********************************************************************/
class CClient : public QObject
{
Q_OBJECT
public:
CClient ( const quint16 iPortNumber );
void Start();
void Stop();
bool IsRunning() { return Sound.IsRunning(); }
bool SetServerAddr ( QString strNAddr );
double MicLevelL() { return SignalLevelMeter.MicLevelLeft(); }
double MicLevelR() { return SignalLevelMeter.MicLevelRight(); }
bool IsConnected() { return Channel.IsConnected(); }
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
bool GetOpenChatOnNewMessage() const { return bOpenChatOnNewMessage; }
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
EGUIDesign GetGUIDesign() const { return eGUIDesign; }
void SetGUIDesign ( const EGUIDesign bNGD ) { eGUIDesign = bNGD; }
bool GetCELTHighQuality() const { return bCeltDoHighQuality; }
void SetCELTHighQuality ( const bool bNCeltHighQualityFlag );
bool GetUseStereo() const { return bUseStereo; }
void SetUseStereo ( const bool bNUseStereo );
int GetAudioInFader() const { return iAudioInFader; }
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
int GetReverbLevel() const { return iReverbLevel; }
void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; }
bool IsReverbOnLeftChan() const { return bReverbOnLeftChan; }
void SetReverbOnLeftChan ( const bool bIL )
{
bReverbOnLeftChan = bIL;
AudioReverbL.Clear();
AudioReverbR.Clear();
}
void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; }
bool GetDoAutoSockBufSize() const { return bDoAutoSockBufSize; }
void SetSockBufNumFrames ( const int iNumBlocks )
{
// only change parameter if new parameter is different from current one
if ( Channel.GetSockBufNumFrames() != iNumBlocks )
{
// set the new socket size (number of frames)
if ( !Channel.SetSockBufNumFrames ( iNumBlocks ) )
{
// if setting of socket buffer size was successful,
// tell the server that size has changed
Channel.CreateJitBufMes ( iNumBlocks );
}
}
}
int GetSockBufNumFrames() { return Channel.GetSockBufNumFrames(); }
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
// sound card device selection
int GetSndCrdNumDev() { return Sound.GetNumDev(); }
QString GetSndCrdDeviceName ( const int iDiD )
{ return Sound.GetDeviceName ( iDiD ); }
QString SetSndCrdDev ( const int iNewDev );
int GetSndCrdDev() { return Sound.GetDev(); }
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
// sound card channel selection
int GetSndCrdNumInputChannels() { return Sound.GetNumInputChannels(); }
QString GetSndCrdInputChannelName ( const int iDiD ) { return Sound.GetInputChannelName ( iDiD ); }
void SetSndCrdLeftInputChannel ( const int iNewChan );
void SetSndCrdRightInputChannel ( const int iNewChan );
int GetSndCrdLeftInputChannel() { return Sound.GetLeftInputChannel(); }
int GetSndCrdRightInputChannel() { return Sound.GetRightInputChannel(); }
int GetSndCrdNumOutputChannels() { return Sound.GetNumOutputChannels(); }
QString GetSndCrdOutputChannelName ( const int iDiD ) { return Sound.GetOutputChannelName ( iDiD ); }
void SetSndCrdLeftOutputChannel ( const int iNewChan );
void SetSndCrdRightOutputChannel ( const int iNewChan );
int GetSndCrdLeftOutputChannel() { return Sound.GetLeftOutputChannel(); }
int GetSndCrdRightOutputChannel() { return Sound.GetRightOutputChannel(); }
void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor );
int GetSndCrdPrefFrameSizeFactor()
{ return iSndCrdPrefFrameSizeFactor; }
int GetSndCrdActualMonoBlSize()
{
// the actual sound card mono block size depends on whether a
// sound card conversion buffer is used or not
if ( bSndCrdConversionBufferRequired )
{
return iSndCardMonoBlockSizeSamConvBuff;
}
else
{
return iMonoBlockSizeSam;
}
}
int GetSystemMonoBlSize() { return iMonoBlockSizeSam; }
int GetSndCrdConvBufAdditionalDelayMonoBlSize()
{
if ( bSndCrdConversionBufferRequired )
{
// by introducing the conversion buffer we also introduce additional
// delay which equals the "internal" mono buffer size
return iMonoBlockSizeSam;
}
else
{
return 0;
}
}
bool GetFraSiFactPrefSupported() { return bFraSiFactPrefSupported; }
bool GetFraSiFactDefSupported() { return bFraSiFactDefSupported; }
bool GetFraSiFactSafeSupported() { return bFraSiFactSafeSupported; }
void SetRemoteChanGain ( const int iId, const double dGain )
{ Channel.SetRemoteChanGain ( iId, dGain ); }
void SetRemoteName() { Channel.SetRemoteName ( strName ); }
void CreateChatTextMes ( const QString& strChatText )
{ Channel.CreateChatTextMes ( strChatText ); }
void CreatePingMes()
{ Channel.CreatePingMes ( PreparePingMessage() ); }
void CreateCLPingMes ( const CHostAddress& InetAddr )
{ ConnLessProtocol.CreateCLPingMes ( InetAddr, PreparePingMessage() ); }
void CreateCLReqServerListMes ( const CHostAddress& InetAddr )
{ ConnLessProtocol.CreateCLReqServerListMes ( InetAddr ); }
int EstimatedOverallDelay ( const int iPingTimeMs );
CChannel* GetChannel() { return &Channel; }
// settings
CVector<QString> vstrIPAddress;
QString strName;
#ifdef LLCON_VST_PLUGIN
// VST version must have direct access to sound object
CSound* GetSound() { return &Sound; }
#endif
protected:
// callback function must be static, otherwise it does not work
static void AudioCallback ( CVector<short>& psData, void* arg );
void Init();
void ProcessSndCrdAudioData ( CVector<short>& vecsStereoSndCrd );
void ProcessAudioDataIntern ( CVector<short>& vecsStereoSndCrd );
void UpdateSocketBufferSize();
int PreparePingMessage();
int EvaluatePingMessage ( const int iMs );
// only one channel is needed for client application
CChannel Channel;
CProtocol ConnLessProtocol;
bool bDoAutoSockBufSize;
// audio encoder/decoder
CELTMode* CeltModeMono;
CELTEncoder* CeltEncoderMono;
CELTDecoder* CeltDecoderMono;
CELTMode* CeltModeStereo;
CELTEncoder* CeltEncoderStereo;
CELTDecoder* CeltDecoderStereo;
int iCeltNumCodedBytes;
bool bCeltDoHighQuality;
bool bUseStereo;
CVector<unsigned char> vecCeltData;
CSocket Socket;
CSound Sound;
CStereoSignalLevelMeter SignalLevelMeter;
CVector<uint8_t> vecbyNetwData;
int iAudioInFader;
bool bReverbOnLeftChan;
int iReverbLevel;
CAudioReverb AudioReverbL;
CAudioReverb AudioReverbR;
int iSndCrdPrefFrameSizeFactor;
int iSndCrdFrameSizeFactor;
bool bSndCrdConversionBufferRequired;
int iSndCardMonoBlockSizeSamConvBuff;
CBufferBase<int16_t> SndCrdConversionBufferIn;
CBufferBase<int16_t> SndCrdConversionBufferOut;
CVector<int16_t> vecDataConvBuf;
bool bFraSiFactPrefSupported;
bool bFraSiFactDefSupported;
bool bFraSiFactSafeSupported;
int iMonoBlockSizeSam;
int iStereoBlockSizeSam;
bool bOpenChatOnNewMessage;
EGUIDesign eGUIDesign;
CVector<int16_t> vecsAudioSndCrdMono;
CVector<double> vecdAudioStereo;
CVector<int16_t> vecsNetwork;
// for ping measurement
CPreciseTime PreciseTime;
CCycleTimeVariance CycleTimeVariance;
public slots:
void OnSendProtMessage ( 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 OnCLPingWithNumClientsReceived ( CHostAddress InetAddr,
int iMs,
int iNumClients );
void OnSndCrdReinitRequest();
signals:
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ChatTextReceived ( QString strChatText );
void PingTimeReceived ( int iPingTime );
void CLServerListReceived ( CHostAddress InetAddr,
CVector<CServerInfo> vecServerInfo );
void CLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
int iPingTime,
int iNumClients );
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 );
pNewListViewItem->setFont ( 1, CurPingTimeFont );
// number of clients
pNewListViewItem->setText ( 2,
QString().setNum ( vecServerInfo[iIdx].iNumClients ) );
// server location (city and country)
QString strLocation = vecServerInfo[iIdx].strCity;
if ( !strLocation.isEmpty() )
{
strLocation += ", ";
}
strLocation +=
QLocale::countryToString ( vecServerInfo[iIdx].eCountry );
// server country
pNewListViewItem->setText ( 3,
QLocale::countryToString ( vecServerInfo[iIdx].eCountry ) );
pNewListViewItem->setText ( 3, strLocation );
// store host address
pNewListViewItem->setData ( 0, Qt::UserRole,
@ -294,9 +297,10 @@ void CConnectDlg::OnTimerPing()
}
}
void CConnectDlg::SetPingTimeResult ( CHostAddress& InetAddr,
const int iPingTime,
const int iPingTimeLEDColor )
void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
const int iPingTime,
const int iPingTimeLEDColor,
const int iNumClients )
{
// apply the received ping time to the correct server list entry
const int iServerListLen = ListViewServers->topLevelItemCount();
@ -332,6 +336,10 @@ void CConnectDlg::SetPingTimeResult ( CHostAddress& InetAddr,
ListViewServers->topLevelItem ( iIdx )->
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
ListViewServers->topLevelItem ( iIdx )->setHidden ( false );
}

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@ -1,156 +1,152 @@
/******************************************************************************\
* Copyright (c) 2004-2011
*
* Author(s):
* Volker Fischer
*
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
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
and a mechanism implemented in the protocol opens the firewall similar to STUN.
REQUIREMENTS:
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
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 central server or not.
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
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
like reliability of the server, etc.
CONNECTION PROCESS:
The private server contacts the central server and registers through some
protocol mechanism.
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
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
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
private network.
******************************************************************************
*
* 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
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* 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
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* 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.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
#if !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ )
#define SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_
#include <qobject.h>
#include <qlocale.h>
#include <qlist.h>
#include <qtimer.h>
#include <qmutex.h>
#include "global.h"
#include "util.h"
#include "protocol.h"
/* Classes ********************************************************************/
class CServerListEntry : public CServerInfo
{
public:
CServerListEntry() :
CServerInfo ( CHostAddress(),
"",
"",
QLocale::AnyCountry,
"",
0,
0,
false ) { UpdateRegistration(); }
CServerListEntry ( const CHostAddress& NHAddr,
const QString& NsName,
const QString& NsTopic,
const QLocale::Country& NeCountry,
const QString& NsCity,
const int NiNumClients,
const int NiMaxNumClients,
const bool NbPermOnline)
: CServerInfo ( NHAddr,
NsName,
NsTopic,
NeCountry,
NsCity,
NiNumClients,
NiMaxNumClients,
NbPermOnline ) { UpdateRegistration(); }
CServerListEntry ( const CHostAddress& NHAddr,
const CServerCoreInfo& NewCoreServerInfo )
: CServerInfo ( NHAddr,
NewCoreServerInfo.strName,
NewCoreServerInfo.strTopic,
NewCoreServerInfo.eCountry,
NewCoreServerInfo.strCity,
NewCoreServerInfo.iNumClients,
NewCoreServerInfo.iMaxNumClients,
NewCoreServerInfo.bPermanentOnline )
{ UpdateRegistration(); }
void UpdateRegistration() { RegisterTime.start(); }
public:
// time on which the entry was registered
QTime RegisterTime;
};
class CServerListManager : public QObject
{
Q_OBJECT
public:
CServerListManager ( const QString& sNCentServAddr,
CProtocol* pNConLProt );
void SetEnabled ( const bool bState );
bool GetEnabled() const { return bEnabled; }
bool GetIsCentralServer() const { return bIsCentralServer; }
void RegisterServer ( const CHostAddress& InetAddr,
const CServerCoreInfo& ServerInfo );
void QueryServerList ( const CHostAddress& InetAddr );
protected:
QTimer TimerPollList;
QTimer TimerRegistering;
QMutex Mutex;
QList<CServerListEntry> ServerList;
QString strCentralServerAddress;
bool bEnabled;
bool bIsCentralServer;
CProtocol* pConnLessProtocol;
public slots:
void OnTimerPollList();
void OnTimerRegistering();
};
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */
/******************************************************************************\
* Copyright (c) 2004-2011
*
* Author(s):
* Volker Fischer
*
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
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
and a mechanism implemented in the protocol opens the firewall similar to STUN.
REQUIREMENTS:
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
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 central server or not.
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
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
like reliability of the server, etc.
CONNECTION PROCESS:
The private server contacts the central server and registers through some
protocol mechanism.
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
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
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
private network.
******************************************************************************
*
* 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
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* 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
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* 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.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
#if !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ )
#define SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_
#include <qobject.h>
#include <qlocale.h>
#include <qlist.h>
#include <qtimer.h>
#include <qmutex.h>
#include "global.h"
#include "util.h"
#include "protocol.h"
/* Classes ********************************************************************/
class CServerListEntry : public CServerInfo
{
public:
CServerListEntry() :
CServerInfo ( CHostAddress(),
"",
"",
QLocale::AnyCountry,
"",
0,
false ) { UpdateRegistration(); }
CServerListEntry ( const CHostAddress& NHAddr,
const QString& NsName,
const QString& NsTopic,
const QLocale::Country& NeCountry,
const QString& NsCity,
const int NiMaxNumClients,
const bool NbPermOnline)
: CServerInfo ( NHAddr,
NsName,
NsTopic,
NeCountry,
NsCity,
NiMaxNumClients,
NbPermOnline ) { UpdateRegistration(); }
CServerListEntry ( const CHostAddress& NHAddr,
const CServerCoreInfo& NewCoreServerInfo )
: CServerInfo ( NHAddr,
NewCoreServerInfo.strName,
NewCoreServerInfo.strTopic,
NewCoreServerInfo.eCountry,
NewCoreServerInfo.strCity,
NewCoreServerInfo.iMaxNumClients,
NewCoreServerInfo.bPermanentOnline )
{ UpdateRegistration(); }
void UpdateRegistration() { RegisterTime.start(); }
public:
// time on which the entry was registered
QTime RegisterTime;
};
class CServerListManager : public QObject
{
Q_OBJECT
public:
CServerListManager ( const QString& sNCentServAddr,
CProtocol* pNConLProt );
void SetEnabled ( const bool bState );
bool GetEnabled() const { return bEnabled; }
bool GetIsCentralServer() const { return bIsCentralServer; }
void RegisterServer ( const CHostAddress& InetAddr,
const CServerCoreInfo& ServerInfo );
void QueryServerList ( const CHostAddress& InetAddr );
protected:
QTimer TimerPollList;
QTimer TimerRegistering;
QMutex Mutex;
QList<CServerListEntry> ServerList;
QString strCentralServerAddress;
bool bEnabled;
bool bIsCentralServer;
CProtocol* pConnLessProtocol;
public slots:
void OnTimerPollList();
void OnTimerRegistering();
};
#endif /* !defined ( SERVERLIST_HOIJH8OUWEF_WFEIOBU_3_43445KJIUHF1912__INCLUDED_ ) */

View File

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