From 5bdf759e010af5118852a2f748c31bc71fd922d7 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Fri, 8 Dec 2006 18:19:16 +0000 Subject: [PATCH] preparations for requesting "connected clients list" on a new connection --- src/channel.cpp | 29 ++++++++++++++++++++++++++++- src/channel.h | 14 ++++++++++++++ src/client.h | 1 + src/protocol.cpp | 16 ++++++++++++++++ src/protocol.h | 34 +++++++++++++++++++--------------- 5 files changed, 78 insertions(+), 16 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index 239307d9..9e3e8c1e 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -54,6 +54,18 @@ CChannelSet::CChannelSet() QObject::connect(&vecChannels[7],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh7())); QObject::connect(&vecChannels[8],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh8())); QObject::connect(&vecChannels[9],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh9())); + + // request connected clients list + QObject::connect(&vecChannels[0],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh0())); + QObject::connect(&vecChannels[1],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh1())); + QObject::connect(&vecChannels[2],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh2())); + QObject::connect(&vecChannels[3],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh3())); + QObject::connect(&vecChannels[4],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh4())); + QObject::connect(&vecChannels[5],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh5())); + QObject::connect(&vecChannels[6],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh6())); + QObject::connect(&vecChannels[7],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh7())); + QObject::connect(&vecChannels[8],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh8())); + QObject::connect(&vecChannels[9],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh9())); } void CChannelSet::CreateAndSendChanListForAllConClients() @@ -204,7 +216,18 @@ bool CChannelSet::PutData ( const CVector& vecbyRecBuf, // requested if ( bCreateChanList ) { - CreateAndSendChanListForAllConClients(); + + + +// TODO list is only send for new connected clients after request, only +// the already connected clients get the list automatically, because they +// don't know when new clients connect! + +// TODO use "void OnReqConnClientsListChx() {}" for sending list to specific client + +CreateAndSendChanListForAllConClients(); // <- replace this + + } } Mutex.unlock(); @@ -348,6 +371,10 @@ CChannel::CChannel() : sName ( "" ), SIGNAL ( ReqJittBufSize() ), SIGNAL ( ReqJittBufSize() ) ); + QObject::connect ( &Protocol, + SIGNAL ( ReqConnClientsList() ), + SIGNAL ( ReqConnClientsList() ) ); + QObject::connect ( &Protocol, SIGNAL ( ConClientListMesReceived ( CVector ) ), SIGNAL ( ConClientListMesReceived ( CVector ) ) ); diff --git a/src/channel.h b/src/channel.h index 9b7fba3c..832e362c 100755 --- a/src/channel.h +++ b/src/channel.h @@ -103,6 +103,7 @@ public: } } void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); } + void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); } void CreateNetwBlSiFactMes ( const int iNetwBlSiFact ) { @@ -171,6 +172,7 @@ signals: void MessReadyForSending ( CVector vecMessage ); void NewConnection(); void ReqJittBufSize(); + void ReqConnClientsList(); void ConClientListMesReceived ( CVector vecChanInfo ); void ProtocolStatus ( bool bOk ); }; @@ -245,6 +247,18 @@ public slots: void OnNewConnectionCh8() {vecChannels[8].CreateReqJitBufMes();} void OnNewConnectionCh9() {vecChannels[9].CreateReqJitBufMes();} +// TODO + void OnReqConnClientsListCh0() {} + void OnReqConnClientsListCh1() {} + void OnReqConnClientsListCh2() {} + void OnReqConnClientsListCh3() {} + void OnReqConnClientsListCh4() {} + void OnReqConnClientsListCh5() {} + void OnReqConnClientsListCh6() {} + void OnReqConnClientsListCh7() {} + void OnReqConnClientsListCh8() {} + void OnReqConnClientsListCh9() {} + signals: void MessReadyForSending ( int iChID, CVector vecMessage ); }; diff --git a/src/client.h b/src/client.h index 1cdd5439..aa51ebee 100755 --- a/src/client.h +++ b/src/client.h @@ -168,6 +168,7 @@ public slots: void OnSendProtMessage ( CVector vecMessage ); void OnReqJittBufSize(); void OnProtocolStatus ( bool bOk ); + void OnNewConnection() { Channel.CreateReqConnClientsList(); } signals: void ConClientListMesReceived ( CVector vecChanInfo ); diff --git a/src/protocol.cpp b/src/protocol.cpp index 1821b8e9..b15e5ed2 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -77,6 +77,11 @@ MESSAGES | 1 byte channel ID | 4 bytes IP address | 2 bytes number n | n bytes UTF-8 string | +-------------------+--------------------+------------------+----------------------+ +- Request connected clients list: PROTMESSID_REQ_CONN_CLIENTS_LIST + + note: does not have any data -> n = 0 + + * ****************************************************************************** * @@ -530,6 +535,17 @@ void CProtocol:: EvaluateConClientListMes ( unsigned int iPos, const CVector ( 0 ) ); +} + +void CProtocol::EvaluateReqConnClientsList ( unsigned int iPos, const CVector& vecData ) +{ + // invoke message action + emit ReqConnClientsList(); +} + /******************************************************************************\ * Message generation (parsing) * diff --git a/src/protocol.h b/src/protocol.h index a70d8e41..09a7ae1e 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -35,15 +35,16 @@ /* 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_PING 12 // for measuring ping time -#define PROTMESSID_NET_BLSI_FACTOR 13 // network buffer size factor -#define PROTMESSID_CHANNEL_GAIN 14 // set channel gain for mix -#define PROTMESSID_CONN_CLIENTS_LIST 15 // connected client list -#define PROTMESSID_SERVER_FULL 16 +#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_PING 12 // for measuring ping time +#define PROTMESSID_NET_BLSI_FACTOR 13 // network buffer size factor +#define PROTMESSID_CHANNEL_GAIN 14 // set channel gain for mix +#define PROTMESSID_CONN_CLIENTS_LIST 15 // connected client list +#define PROTMESSID_SERVER_FULL 16 // server full message +#define PROTMESSID_REQ_CONN_CLIENTS_LIST 17 // request connected client list // lengths of message as defined in protocol.cpp file #define MESS_HEADER_LENGTH_BYTE 5 /* ID, cnt, length */ @@ -63,6 +64,7 @@ public: void CreateJitBufMes ( const int iJitBufSize ); void CreateReqJitBufMes(); + void CreateReqConnClientsList(); void CreateServerFullMes(); void CreateNetwBlSiFactMes ( const int iNetwBlSiFact ); void CreateChanGainMes ( const int iChanID, const double dGain ); @@ -127,12 +129,13 @@ protected: void CreateAndSendMessage ( const int iID, const CVector& vecData ); - void EvaluateJitBufMes ( unsigned int iPos, const CVector& vecData ); - void EvaluateReqJitBufMes ( unsigned int iPos, const CVector& vecData ); - void EvaluateServerFullMes ( unsigned int iPos, const CVector& vecData ); - void EvaluateNetwBlSiFactMes ( unsigned int iPos, const CVector& vecData ); - void EvaluateChanGainMes ( unsigned int iPos, const CVector& vecData ); - void EvaluateConClientListMes ( unsigned int iPos, const CVector& vecData ); + void EvaluateJitBufMes ( unsigned int iPos, const CVector& vecData ); + void EvaluateReqJitBufMes ( unsigned int iPos, const CVector& vecData ); + void EvaluateReqConnClientsList ( unsigned int iPos, const CVector& vecData ); + void EvaluateServerFullMes ( unsigned int iPos, const CVector& vecData ); + void EvaluateNetwBlSiFactMes ( unsigned int iPos, const CVector& vecData ); + void EvaluateChanGainMes ( unsigned int iPos, const CVector& vecData ); + void EvaluateConClientListMes ( unsigned int iPos, const CVector& vecData ); int iOldRecID, iOldRecCnt; @@ -156,6 +159,7 @@ signals: void ChangeChanGain ( int iChanID, double dNewGain ); void ConClientListMesReceived ( CVector vecChanInfo ); void ReqJittBufSize(); + void ReqConnClientsList(); void ServerFull(); };