fixed problem with receiving connected clients list on new connection
This commit is contained in:
parent
5bdf759e01
commit
fc0f1d6aae
7 changed files with 174 additions and 124 deletions
|
@ -30,6 +30,12 @@
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
CChannelSet::CChannelSet()
|
CChannelSet::CChannelSet()
|
||||||
{
|
{
|
||||||
|
// enable all channels
|
||||||
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
|
{
|
||||||
|
vecChannels[i].SetEnable ( true );
|
||||||
|
}
|
||||||
|
|
||||||
// make sure we have MAX_NUM_CHANNELS connections!!!
|
// make sure we have MAX_NUM_CHANNELS connections!!!
|
||||||
// send message
|
// send message
|
||||||
QObject::connect(&vecChannels[0],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh0(CVector<uint8_t>)));
|
QObject::connect(&vecChannels[0],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh0(CVector<uint8_t>)));
|
||||||
|
@ -56,25 +62,24 @@ CChannelSet::CChannelSet()
|
||||||
QObject::connect(&vecChannels[9],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh9()));
|
QObject::connect(&vecChannels[9],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh9()));
|
||||||
|
|
||||||
// request connected clients list
|
// request connected clients list
|
||||||
QObject::connect(&vecChannels[0],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh0()));
|
QObject::connect(&vecChannels[0],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh0()));
|
||||||
QObject::connect(&vecChannels[1],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh1()));
|
QObject::connect(&vecChannels[1],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh1()));
|
||||||
QObject::connect(&vecChannels[2],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh2()));
|
QObject::connect(&vecChannels[2],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh2()));
|
||||||
QObject::connect(&vecChannels[3],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh3()));
|
QObject::connect(&vecChannels[3],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh3()));
|
||||||
QObject::connect(&vecChannels[4],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh4()));
|
QObject::connect(&vecChannels[4],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh4()));
|
||||||
QObject::connect(&vecChannels[5],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh5()));
|
QObject::connect(&vecChannels[5],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh5()));
|
||||||
QObject::connect(&vecChannels[6],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh6()));
|
QObject::connect(&vecChannels[6],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh6()));
|
||||||
QObject::connect(&vecChannels[7],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh7()));
|
QObject::connect(&vecChannels[7],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh7()));
|
||||||
QObject::connect(&vecChannels[8],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh8()));
|
QObject::connect(&vecChannels[8],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh8()));
|
||||||
QObject::connect(&vecChannels[9],SIGNAL(ReqConnClientsList()),this,SLOT(OnNewConnectionCh9()));
|
QObject::connect(&vecChannels[9],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh9()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChannelSet::CreateAndSendChanListForAllConClients()
|
CVector<CChannelShortInfo> CChannelSet::CreateChannelList()
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
CVector<CChannelShortInfo> vecChanInfo ( 0 );
|
CVector<CChannelShortInfo> vecChanInfo ( 0 );
|
||||||
|
|
||||||
// look for free channels
|
// look for free channels
|
||||||
for ( i = 0; i < MAX_NUM_CHANNELS; i++ )
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
{
|
{
|
||||||
if ( vecChannels[i].IsConnected() )
|
if ( vecChannels[i].IsConnected() )
|
||||||
{
|
{
|
||||||
|
@ -86,10 +91,19 @@ void CChannelSet::CreateAndSendChanListForAllConClients()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now send connected channels list to all connected clients
|
return vecChanInfo;
|
||||||
for ( i = 0; i < MAX_NUM_CHANNELS; i++ )
|
}
|
||||||
|
|
||||||
|
void CChannelSet::CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID )
|
||||||
{
|
{
|
||||||
if ( vecChannels[i].IsConnected() )
|
// create channel list
|
||||||
|
CVector<CChannelShortInfo> vecChanInfo ( CChannelSet::CreateChannelList() );
|
||||||
|
|
||||||
|
// now send connected channels list to all connected clients except for
|
||||||
|
// the channel with the ID "iCurChanID"
|
||||||
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
|
{
|
||||||
|
if ( ( vecChannels[i].IsConnected() ) && ( i != iCurChanID ) )
|
||||||
{
|
{
|
||||||
// send message
|
// send message
|
||||||
vecChannels[i].CreateConClientListMes ( vecChanInfo );
|
vecChannels[i].CreateConClientListMes ( vecChanInfo );
|
||||||
|
@ -97,6 +111,15 @@ void CChannelSet::CreateAndSendChanListForAllConClients()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannelSet::CreateAndSendChanListForThisChan ( const int iCurChanID )
|
||||||
|
{
|
||||||
|
// create channel list
|
||||||
|
CVector<CChannelShortInfo> vecChanInfo ( CChannelSet::CreateChannelList() );
|
||||||
|
|
||||||
|
// now send connected channels list to the channel with the ID "iCurChanID"
|
||||||
|
vecChannels[iCurChanID].CreateConClientListMes ( vecChanInfo );
|
||||||
|
}
|
||||||
|
|
||||||
int CChannelSet::GetFreeChan()
|
int CChannelSet::GetFreeChan()
|
||||||
{
|
{
|
||||||
// look for a free channel
|
// look for a free channel
|
||||||
|
@ -216,18 +239,10 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
|
||||||
// requested
|
// requested
|
||||||
if ( bCreateChanList )
|
if ( bCreateChanList )
|
||||||
{
|
{
|
||||||
|
// connected clients 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 list is only send for new connected clients after request, only
|
CreateAndSendChanListForAllExceptThisChan ( iCurChanID );
|
||||||
// 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();
|
Mutex.unlock();
|
||||||
|
@ -384,6 +399,18 @@ CChannel::CChannel() : sName ( "" ),
|
||||||
this, SLOT ( OnNetwBlSiFactChange ( int ) ) );
|
this, SLOT ( OnNetwBlSiFactChange ( int ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::SetEnable ( const bool bNEnStat )
|
||||||
|
{
|
||||||
|
// set internal parameter
|
||||||
|
bIsEnabled = bNEnStat;
|
||||||
|
|
||||||
|
// if channel is not enabled, reset time out count
|
||||||
|
if ( !bNEnStat )
|
||||||
|
{
|
||||||
|
iConTimeOut = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CChannel::SetNetwInBlSiFact ( const int iNewBlockSizeFactor )
|
void CChannel::SetNetwInBlSiFact ( const int iNewBlockSizeFactor )
|
||||||
{
|
{
|
||||||
// store new value
|
// store new value
|
||||||
|
@ -492,6 +519,9 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
||||||
int iNumBytes )
|
int iNumBytes )
|
||||||
{
|
{
|
||||||
EPutDataStat eRet = PS_GEN_ERROR;
|
EPutDataStat eRet = PS_GEN_ERROR;
|
||||||
|
|
||||||
|
if ( bIsEnabled )
|
||||||
|
{
|
||||||
bool bNewConnection = false;
|
bool bNewConnection = false;
|
||||||
bool bIsAudioPacket = false;
|
bool bIsAudioPacket = false;
|
||||||
|
|
||||||
|
@ -585,6 +615,7 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) {
|
||||||
|
|
||||||
emit NewConnection();
|
emit NewConnection();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return eRet;
|
return eRet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,16 +36,16 @@
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
/* Set the time-out for the input buffer until the state changes from
|
// Set the time-out for the input buffer until the state changes from
|
||||||
connected to not-connected (the actual time depends on the way the error
|
// connected to not-connected (the actual time depends on the way the error
|
||||||
correction is implemented) */
|
// correction is implemented)
|
||||||
#define CON_TIME_OUT_SEC_MAX 5 // seconds
|
#define CON_TIME_OUT_SEC_MAX 5 // seconds
|
||||||
|
|
||||||
/* maximum number of internet connections (channels) */
|
// maximum number of internet connections (channels)
|
||||||
// if you want to change this paramter, change the connections in this class, too!
|
// if you want to change this paramter, change the connections in this class, too!
|
||||||
#define MAX_NUM_CHANNELS 10 /* max number channels for server */
|
#define MAX_NUM_CHANNELS 10 /* max number channels for server */
|
||||||
|
|
||||||
/* no valid channel number */
|
// no valid channel number
|
||||||
#define INVALID_CHANNEL_ID (MAX_NUM_CHANNELS + 1)
|
#define INVALID_CHANNEL_ID (MAX_NUM_CHANNELS + 1)
|
||||||
|
|
||||||
enum EPutDataStat
|
enum EPutDataStat
|
||||||
|
@ -59,7 +59,7 @@ enum EPutDataStat
|
||||||
|
|
||||||
|
|
||||||
/* Classes ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
/* CChannel ----------------------------------------------------------------- */
|
// CChannel --------------------------------------------------------------------
|
||||||
class CChannel : public QObject
|
class CChannel : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -76,6 +76,9 @@ public:
|
||||||
|
|
||||||
bool IsConnected() const { return iConTimeOut > 0; }
|
bool IsConnected() const { return iConTimeOut > 0; }
|
||||||
|
|
||||||
|
void SetEnable ( const bool bNEnStat );
|
||||||
|
bool IsEnabled() { return bIsEnabled; }
|
||||||
|
|
||||||
void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
|
void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
|
||||||
bool GetAddress ( CHostAddress& RetAddr );
|
bool GetAddress ( CHostAddress& RetAddr );
|
||||||
CHostAddress GetAddress () { return InetAddr; }
|
CHostAddress GetAddress () { return InetAddr; }
|
||||||
|
@ -155,6 +158,8 @@ protected:
|
||||||
int iConTimeOut;
|
int iConTimeOut;
|
||||||
int iConTimeOutStartVal;
|
int iConTimeOutStartVal;
|
||||||
|
|
||||||
|
bool bIsEnabled;
|
||||||
|
|
||||||
int vecNetwInBufSizes[MAX_NET_BLOCK_SIZE_FACTOR];
|
int vecNetwInBufSizes[MAX_NET_BLOCK_SIZE_FACTOR];
|
||||||
|
|
||||||
int iCurNetwInBlSiFact;
|
int iCurNetwInBlSiFact;
|
||||||
|
@ -178,7 +183,7 @@ signals:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* CChannelSet (for server) ------------------------------------------------- */
|
// CChannelSet (for server) ----------------------------------------------------
|
||||||
class CChannelSet : public QObject
|
class CChannelSet : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -203,7 +208,7 @@ public:
|
||||||
CVector<int>& veciNetwOutBlSiFact,
|
CVector<int>& veciNetwOutBlSiFact,
|
||||||
CVector<int>& veciNetwInBlSiFact );
|
CVector<int>& veciNetwInBlSiFact );
|
||||||
|
|
||||||
/* 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(); }
|
||||||
|
|
||||||
|
@ -215,7 +220,9 @@ public:
|
||||||
{ return vecChannels[iChanNum].GetAddress(); }
|
{ return vecChannels[iChanNum].GetAddress(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CreateAndSendChanListForAllConClients();
|
CVector<CChannelShortInfo> CreateChannelList();
|
||||||
|
void CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID );
|
||||||
|
void CreateAndSendChanListForThisChan ( const int iCurChanID );
|
||||||
|
|
||||||
/* do not use the vector class since CChannel does not have appropriate
|
/* do not use the vector class since CChannel does not have appropriate
|
||||||
copy constructor/operator */
|
copy constructor/operator */
|
||||||
|
@ -247,17 +254,16 @@ public slots:
|
||||||
void OnNewConnectionCh8() {vecChannels[8].CreateReqJitBufMes();}
|
void OnNewConnectionCh8() {vecChannels[8].CreateReqJitBufMes();}
|
||||||
void OnNewConnectionCh9() {vecChannels[9].CreateReqJitBufMes();}
|
void OnNewConnectionCh9() {vecChannels[9].CreateReqJitBufMes();}
|
||||||
|
|
||||||
// TODO
|
void OnReqConnClientsListCh0() { CreateAndSendChanListForThisChan ( 0 ); }
|
||||||
void OnReqConnClientsListCh0() {}
|
void OnReqConnClientsListCh1() { CreateAndSendChanListForThisChan ( 1 ); }
|
||||||
void OnReqConnClientsListCh1() {}
|
void OnReqConnClientsListCh2() { CreateAndSendChanListForThisChan ( 2 ); }
|
||||||
void OnReqConnClientsListCh2() {}
|
void OnReqConnClientsListCh3() { CreateAndSendChanListForThisChan ( 3 ); }
|
||||||
void OnReqConnClientsListCh3() {}
|
void OnReqConnClientsListCh4() { CreateAndSendChanListForThisChan ( 4 ); }
|
||||||
void OnReqConnClientsListCh4() {}
|
void OnReqConnClientsListCh5() { CreateAndSendChanListForThisChan ( 5 ); }
|
||||||
void OnReqConnClientsListCh5() {}
|
void OnReqConnClientsListCh6() { CreateAndSendChanListForThisChan ( 6 ); }
|
||||||
void OnReqConnClientsListCh6() {}
|
void OnReqConnClientsListCh7() { CreateAndSendChanListForThisChan ( 7 ); }
|
||||||
void OnReqConnClientsListCh7() {}
|
void OnReqConnClientsListCh8() { CreateAndSendChanListForThisChan ( 8 ); }
|
||||||
void OnReqConnClientsListCh8() {}
|
void OnReqConnClientsListCh9() { CreateAndSendChanListForThisChan ( 9 ); }
|
||||||
void OnReqConnClientsListCh9() {}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void MessReadyForSending ( int iChID, CVector<uint8_t> vecMessage );
|
void MessReadyForSending ( int iChID, CVector<uint8_t> vecMessage );
|
||||||
|
|
|
@ -46,6 +46,9 @@ CClient::CClient() : bRun ( false ), Socket ( &Channel ),
|
||||||
QObject::connect ( &Channel,
|
QObject::connect ( &Channel,
|
||||||
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ),
|
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ),
|
||||||
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ) );
|
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ) );
|
||||||
|
|
||||||
|
QObject::connect ( &Channel, SIGNAL ( NewConnection() ),
|
||||||
|
this, SLOT ( OnNewConnection() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
||||||
|
@ -163,6 +166,9 @@ void CClient::run()
|
||||||
|
|
||||||
|
|
||||||
// runtime phase ------------------------------------------------------------
|
// runtime phase ------------------------------------------------------------
|
||||||
|
// enable channel
|
||||||
|
Channel.SetEnable ( true );
|
||||||
|
|
||||||
bRun = true;
|
bRun = true;
|
||||||
|
|
||||||
// main loop of working thread
|
// main loop of working thread
|
||||||
|
@ -381,6 +387,9 @@ fflush(pFileTest);
|
||||||
TimeLastBlock = CurTime;
|
TimeLastBlock = CurTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disable channel
|
||||||
|
Channel.SetEnable ( false );
|
||||||
|
|
||||||
// reset current signal level and LEDs
|
// reset current signal level and LEDs
|
||||||
SignalLevelMeterL.Reset();
|
SignalLevelMeterL.Reset();
|
||||||
SignalLevelMeterR.Reset();
|
SignalLevelMeterR.Reset();
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>410</width>
|
<width>404</width>
|
||||||
<height>249</height>
|
<height>294</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
|
@ -381,7 +381,7 @@
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>sizePolicy</name>
|
<name>sizePolicy</name>
|
||||||
<sizepolicy>
|
<sizepolicy>
|
||||||
<hsizetype>1</hsizetype>
|
<hsizetype>3</hsizetype>
|
||||||
<vsizetype>1</vsizetype>
|
<vsizetype>1</vsizetype>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
@ -449,7 +449,7 @@
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>sizePolicy</name>
|
<name>sizePolicy</name>
|
||||||
<sizepolicy>
|
<sizepolicy>
|
||||||
<hsizetype>1</hsizetype>
|
<hsizetype>3</hsizetype>
|
||||||
<vsizetype>1</vsizetype>
|
<vsizetype>1</vsizetype>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
/* version and application name (always use this version) */
|
/* version and application name (always use this version) */
|
||||||
#undef VERSION
|
#undef VERSION
|
||||||
#define VERSION "0.9.8cvs"
|
#define VERSION "0.9.9cvs"
|
||||||
#define APP_NAME "llcon"
|
#define APP_NAME "llcon"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -242,13 +242,12 @@ void CLlconClientDlg::OnConnectDisconBut ()
|
||||||
|
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
/*
|
|
||||||
// make old controls invisible
|
// make old controls invisible
|
||||||
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
{
|
{
|
||||||
vecpChanFader[i]->Hide();
|
vecpChanFader[i]->Hide();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,6 +338,11 @@ for ( int i = 0; i < iNumBytes; i++ ) {
|
||||||
|
|
||||||
EvaluateConClientListMes ( iPos, vecData );
|
EvaluateConClientListMes ( iPos, vecData );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROTMESSID_REQ_CONN_CLIENTS_LIST:
|
||||||
|
|
||||||
|
EvaluateReqConnClientsList ( iPos, vecData );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send acknowledge message
|
// send acknowledge message
|
||||||
|
|
Loading…
Reference in a new issue