connected client list is now updated for all other clients if one channel is disconnected
This commit is contained in:
parent
fc0f1d6aae
commit
f3ce0f8ea2
3 changed files with 69 additions and 14 deletions
|
@ -94,6 +94,22 @@ CVector<CChannelShortInfo> CChannelSet::CreateChannelList()
|
||||||
return vecChanInfo;
|
return vecChanInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannelSet::CreateAndSendChanListForAllConChannels()
|
||||||
|
{
|
||||||
|
// create channel list
|
||||||
|
CVector<CChannelShortInfo> vecChanInfo ( CChannelSet::CreateChannelList() );
|
||||||
|
|
||||||
|
// now send connected channels list to all connected clients
|
||||||
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
|
{
|
||||||
|
if ( vecChannels[i].IsConnected() )
|
||||||
|
{
|
||||||
|
// send message
|
||||||
|
vecChannels[i].CreateConClientListMes ( vecChanInfo );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CChannelSet::CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID )
|
void CChannelSet::CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID )
|
||||||
{
|
{
|
||||||
// create channel list
|
// create channel list
|
||||||
|
@ -255,6 +271,7 @@ void CChannelSet::GetBlockAllConC ( CVector<int>& vecChanID,
|
||||||
CVector<CVector<double> >& vecvecdGains )
|
CVector<CVector<double> >& vecvecdGains )
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
bool bCreateChanList = false;
|
||||||
|
|
||||||
// init temporal data vector and clear input buffers
|
// init temporal data vector and clear input buffers
|
||||||
CVector<double> vecdData ( MIN_BLOCK_SIZE_SAMPLES );
|
CVector<double> vecdData ( MIN_BLOCK_SIZE_SAMPLES );
|
||||||
|
@ -272,7 +289,14 @@ void CChannelSet::GetBlockAllConC ( CVector<int>& vecChanID,
|
||||||
{
|
{
|
||||||
// read out all input buffers to decrease timeout counter on
|
// read out all input buffers to decrease timeout counter on
|
||||||
// disconnected channels
|
// disconnected channels
|
||||||
const bool bGetOK = vecChannels[i].GetData ( vecdData );
|
const EGetDataStat eGetStat = vecChannels[i].GetData ( vecdData );
|
||||||
|
|
||||||
|
// if channel was just disconnected, set flag that connected
|
||||||
|
// client list is sent to all other clients
|
||||||
|
if ( eGetStat == GS_CHAN_NOW_DISCONNECTED )
|
||||||
|
{
|
||||||
|
bCreateChanList = true;
|
||||||
|
}
|
||||||
|
|
||||||
if ( vecChannels[i].IsConnected() )
|
if ( vecChannels[i].IsConnected() )
|
||||||
{
|
{
|
||||||
|
@ -285,7 +309,7 @@ void CChannelSet::GetBlockAllConC ( CVector<int>& vecChanID,
|
||||||
vecvecdData[iOldSize] = vecdData;
|
vecvecdData[iOldSize] = vecdData;
|
||||||
|
|
||||||
// send message for get status (for GUI)
|
// send message for get status (for GUI)
|
||||||
if ( bGetOK )
|
if ( eGetStat == GS_BUFFER_OK )
|
||||||
{
|
{
|
||||||
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, i );
|
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, i );
|
||||||
}
|
}
|
||||||
|
@ -312,6 +336,13 @@ void CChannelSet::GetBlockAllConC ( CVector<int>& vecChanID,
|
||||||
vecvecdGains[i][j] = vecChannels[i].GetGain( vecChanID[j] );
|
vecvecdGains[i][j] = vecChannels[i].GetGain( vecChanID[j] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create channel list message if requested
|
||||||
|
if ( bCreateChanList )
|
||||||
|
{
|
||||||
|
// update channel list for all currently connected clients
|
||||||
|
CreateAndSendChanListForAllConChannels();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Mutex.unlock(); // release mutex
|
Mutex.unlock(); // release mutex
|
||||||
}
|
}
|
||||||
|
@ -620,26 +651,41 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) {
|
||||||
return eRet;
|
return eRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChannel::GetData ( CVector<double>& vecdData )
|
EGetDataStat CChannel::GetData ( CVector<double>& vecdData )
|
||||||
{
|
{
|
||||||
bool bGetOK = false;
|
// init with ok flag
|
||||||
|
EGetDataStat eGetStatus = GS_BUFFER_OK;
|
||||||
|
|
||||||
Mutex.lock(); // get mutex lock
|
Mutex.lock(); // get mutex lock
|
||||||
{
|
{
|
||||||
bGetOK = SockBuf.Get ( vecdData );
|
if ( !SockBuf.Get ( vecdData ) )
|
||||||
|
|
||||||
if ( !bGetOK )
|
|
||||||
{
|
{
|
||||||
// decrease time-out counter
|
// decrease time-out counter
|
||||||
if ( iConTimeOut > 0 )
|
if ( iConTimeOut > 0 )
|
||||||
{
|
{
|
||||||
iConTimeOut--;
|
iConTimeOut--;
|
||||||
|
|
||||||
|
if ( iConTimeOut == 0 )
|
||||||
|
{
|
||||||
|
// channel is just disconnected
|
||||||
|
eGetStatus = GS_CHAN_NOW_DISCONNECTED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// channel is not yet disconnected but no data in buffer
|
||||||
|
eGetStatus = GS_BUFFER_UNDERRUN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// channel is disconnected
|
||||||
|
eGetStatus = GS_CHAN_NOT_CONNECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mutex.unlock(); // get mutex unlock
|
Mutex.unlock(); // get mutex unlock
|
||||||
|
|
||||||
return bGetOK;
|
return eGetStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<unsigned char> CChannel::PrepSendPacket ( const CVector<short>& vecsNPacket )
|
CVector<unsigned char> CChannel::PrepSendPacket ( const CVector<short>& vecsNPacket )
|
||||||
|
|
|
@ -57,6 +57,14 @@ enum EPutDataStat
|
||||||
PS_PROT_ERR
|
PS_PROT_ERR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum EGetDataStat
|
||||||
|
{
|
||||||
|
GS_BUFFER_OK,
|
||||||
|
GS_BUFFER_UNDERRUN,
|
||||||
|
GS_CHAN_NOW_DISCONNECTED,
|
||||||
|
GS_CHAN_NOT_CONNECTED
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Classes ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
// CChannel --------------------------------------------------------------------
|
// CChannel --------------------------------------------------------------------
|
||||||
|
@ -70,7 +78,7 @@ public:
|
||||||
|
|
||||||
EPutDataStat PutData ( const CVector<unsigned char>& vecbyData,
|
EPutDataStat PutData ( const CVector<unsigned char>& vecbyData,
|
||||||
int iNumBytes );
|
int iNumBytes );
|
||||||
bool GetData ( CVector<double>& vecdData );
|
EGetDataStat GetData ( CVector<double>& vecdData );
|
||||||
|
|
||||||
CVector<unsigned char> PrepSendPacket ( const CVector<short>& vecsNPacket );
|
CVector<unsigned char> PrepSendPacket ( const CVector<short>& vecsNPacket );
|
||||||
|
|
||||||
|
@ -221,6 +229,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CVector<CChannelShortInfo> CreateChannelList();
|
CVector<CChannelShortInfo> CreateChannelList();
|
||||||
|
void CreateAndSendChanListForAllConChannels();
|
||||||
void CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID );
|
void CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID );
|
||||||
void CreateAndSendChanListForThisChan ( const int iCurChanID );
|
void CreateAndSendChanListForThisChan ( const int iCurChanID );
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ void CClient::run()
|
||||||
Channel.GetAddress () );
|
Channel.GetAddress () );
|
||||||
|
|
||||||
// receive a new block
|
// receive a new block
|
||||||
if ( Channel.GetData ( vecdNetwData ) )
|
if ( Channel.GetData ( vecdNetwData ) == GS_BUFFER_OK )
|
||||||
{
|
{
|
||||||
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN );
|
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue