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()
|
||||
{
|
||||
// enable all channels
|
||||
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||
{
|
||||
vecChannels[i].SetEnable ( true );
|
||||
}
|
||||
|
||||
// make sure we have MAX_NUM_CHANNELS connections!!!
|
||||
// send message
|
||||
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()));
|
||||
|
||||
// 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()));
|
||||
QObject::connect(&vecChannels[0],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh0()));
|
||||
QObject::connect(&vecChannels[1],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh1()));
|
||||
QObject::connect(&vecChannels[2],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh2()));
|
||||
QObject::connect(&vecChannels[3],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh3()));
|
||||
QObject::connect(&vecChannels[4],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh4()));
|
||||
QObject::connect(&vecChannels[5],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh5()));
|
||||
QObject::connect(&vecChannels[6],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh6()));
|
||||
QObject::connect(&vecChannels[7],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh7()));
|
||||
QObject::connect(&vecChannels[8],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh8()));
|
||||
QObject::connect(&vecChannels[9],SIGNAL(ReqConnClientsList()),this,SLOT(OnReqConnClientsListCh9()));
|
||||
}
|
||||
|
||||
void CChannelSet::CreateAndSendChanListForAllConClients()
|
||||
CVector<CChannelShortInfo> CChannelSet::CreateChannelList()
|
||||
{
|
||||
int i;
|
||||
CVector<CChannelShortInfo> vecChanInfo ( 0 );
|
||||
|
||||
// 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() )
|
||||
{
|
||||
|
@ -86,10 +91,19 @@ void CChannelSet::CreateAndSendChanListForAllConClients()
|
|||
}
|
||||
}
|
||||
|
||||
// now send connected channels list to all connected clients
|
||||
for ( i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||
return vecChanInfo;
|
||||
}
|
||||
|
||||
void CChannelSet::CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID )
|
||||
{
|
||||
// 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() )
|
||||
if ( ( vecChannels[i].IsConnected() ) && ( i != iCurChanID ) )
|
||||
{
|
||||
// send message
|
||||
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()
|
||||
{
|
||||
// look for a free channel
|
||||
|
@ -216,18 +239,10 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
|
|||
// requested
|
||||
if ( bCreateChanList )
|
||||
{
|
||||
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
// 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
|
||||
CreateAndSendChanListForAllExceptThisChan ( iCurChanID );
|
||||
}
|
||||
}
|
||||
Mutex.unlock();
|
||||
|
@ -384,6 +399,18 @@ CChannel::CChannel() : sName ( "" ),
|
|||
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 )
|
||||
{
|
||||
// store new value
|
||||
|
@ -492,6 +519,9 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
|||
int iNumBytes )
|
||||
{
|
||||
EPutDataStat eRet = PS_GEN_ERROR;
|
||||
|
||||
if ( bIsEnabled )
|
||||
{
|
||||
bool bNewConnection = false;
|
||||
bool bIsAudioPacket = false;
|
||||
|
||||
|
@ -585,6 +615,7 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) {
|
|||
|
||||
emit NewConnection();
|
||||
}
|
||||
}
|
||||
|
||||
return eRet;
|
||||
}
|
||||
|
|
|
@ -36,16 +36,16 @@
|
|||
|
||||
|
||||
/* Definitions ****************************************************************/
|
||||
/* 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
|
||||
correction is implemented) */
|
||||
// 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
|
||||
// correction is implemented)
|
||||
#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!
|
||||
#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)
|
||||
|
||||
enum EPutDataStat
|
||||
|
@ -59,7 +59,7 @@ enum EPutDataStat
|
|||
|
||||
|
||||
/* Classes ********************************************************************/
|
||||
/* CChannel ----------------------------------------------------------------- */
|
||||
// CChannel --------------------------------------------------------------------
|
||||
class CChannel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -76,6 +76,9 @@ public:
|
|||
|
||||
bool IsConnected() const { return iConTimeOut > 0; }
|
||||
|
||||
void SetEnable ( const bool bNEnStat );
|
||||
bool IsEnabled() { return bIsEnabled; }
|
||||
|
||||
void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
|
||||
bool GetAddress ( CHostAddress& RetAddr );
|
||||
CHostAddress GetAddress () { return InetAddr; }
|
||||
|
@ -155,6 +158,8 @@ protected:
|
|||
int iConTimeOut;
|
||||
int iConTimeOutStartVal;
|
||||
|
||||
bool bIsEnabled;
|
||||
|
||||
int vecNetwInBufSizes[MAX_NET_BLOCK_SIZE_FACTOR];
|
||||
|
||||
int iCurNetwInBlSiFact;
|
||||
|
@ -178,7 +183,7 @@ signals:
|
|||
};
|
||||
|
||||
|
||||
/* CChannelSet (for server) ------------------------------------------------- */
|
||||
// CChannelSet (for server) ----------------------------------------------------
|
||||
class CChannelSet : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -203,7 +208,7 @@ public:
|
|||
CVector<int>& veciNetwOutBlSiFact,
|
||||
CVector<int>& veciNetwInBlSiFact );
|
||||
|
||||
/* access functions for actual channels */
|
||||
// access functions for actual channels
|
||||
bool IsConnected ( const int iChanNum )
|
||||
{ return vecChannels[iChanNum].IsConnected(); }
|
||||
|
||||
|
@ -215,7 +220,9 @@ public:
|
|||
{ return vecChannels[iChanNum].GetAddress(); }
|
||||
|
||||
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
|
||||
copy constructor/operator */
|
||||
|
@ -247,17 +254,16 @@ 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() {}
|
||||
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 ); }
|
||||
|
||||
signals:
|
||||
void MessReadyForSending ( int iChID, CVector<uint8_t> vecMessage );
|
||||
|
|
|
@ -46,6 +46,9 @@ CClient::CClient() : bRun ( false ), Socket ( &Channel ),
|
|||
QObject::connect ( &Channel,
|
||||
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ),
|
||||
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ) );
|
||||
|
||||
QObject::connect ( &Channel, SIGNAL ( NewConnection() ),
|
||||
this, SLOT ( OnNewConnection() ) );
|
||||
}
|
||||
|
||||
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
||||
|
@ -163,6 +166,9 @@ void CClient::run()
|
|||
|
||||
|
||||
// runtime phase ------------------------------------------------------------
|
||||
// enable channel
|
||||
Channel.SetEnable ( true );
|
||||
|
||||
bRun = true;
|
||||
|
||||
// main loop of working thread
|
||||
|
@ -381,6 +387,9 @@ fflush(pFileTest);
|
|||
TimeLastBlock = CurTime;
|
||||
}
|
||||
|
||||
// disable channel
|
||||
Channel.SetEnable ( false );
|
||||
|
||||
// reset current signal level and LEDs
|
||||
SignalLevelMeterL.Reset();
|
||||
SignalLevelMeterR.Reset();
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>410</width>
|
||||
<height>249</height>
|
||||
<width>404</width>
|
||||
<height>294</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
|
@ -381,7 +381,7 @@
|
|||
<property stdset="1">
|
||||
<name>sizePolicy</name>
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
|
@ -449,7 +449,7 @@
|
|||
<property stdset="1">
|
||||
<name>sizePolicy</name>
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
/* version and application name (always use this version) */
|
||||
#undef VERSION
|
||||
#define VERSION "0.9.8cvs"
|
||||
#define VERSION "0.9.9cvs"
|
||||
#define APP_NAME "llcon"
|
||||
|
||||
|
||||
|
|
|
@ -242,13 +242,12 @@ void CLlconClientDlg::OnConnectDisconBut ()
|
|||
|
||||
|
||||
// TEST
|
||||
/*
|
||||
// make old controls invisible
|
||||
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||
{
|
||||
vecpChanFader[i]->Hide();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -338,6 +338,11 @@ for ( int i = 0; i < iNumBytes; i++ ) {
|
|||
|
||||
EvaluateConClientListMes ( iPos, vecData );
|
||||
break;
|
||||
|
||||
case PROTMESSID_REQ_CONN_CLIENTS_LIST:
|
||||
|
||||
EvaluateReqConnClientsList ( iPos, vecData );
|
||||
break;
|
||||
}
|
||||
|
||||
// send acknowledge message
|
||||
|
|
Loading…
Reference in a new issue