clean up "new connection" mechanism for the server (which messages are fired, etc.)

This commit is contained in:
Volker Fischer 2013-05-10 19:37:57 +00:00
parent 8e95b548cb
commit 72b24fedf3
4 changed files with 31 additions and 33 deletions

View file

@ -419,7 +419,6 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
// init flags // init flags
bool bIsProtocolPacket = false; bool bIsProtocolPacket = false;
bool bIsAudioPacket = false;
bool bNewConnection = false; bool bNewConnection = false;
if ( bIsEnabled ) if ( bIsEnabled )
@ -460,9 +459,6 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
// only process audio if packet has correct size // only process audio if packet has correct size
if ( iNumBytes == ( iNetwFrameSize * iNetwFrameSizeFact ) ) if ( iNumBytes == ( iNetwFrameSize * iNetwFrameSizeFact ) )
{ {
// set audio packet flag
bIsAudioPacket = true;
// store new packet in jitter buffer // store new packet in jitter buffer
if ( SockBuf.Put ( vecbyData, iNumBytes ) ) if ( SockBuf.Put ( vecbyData, iNumBytes ) )
{ {
@ -488,6 +484,8 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
// about the audio packet properties via the protocol // about the audio packet properties via the protocol
// check if channel was not connected, this is a new connection // check if channel was not connected, this is a new connection
// (do not fire an event directly since we are inside a mutex
// region -> to avoid a dead-lock)
bNewConnection = !IsConnected(); bNewConnection = !IsConnected();
// reset time-out counter // reset time-out counter
@ -498,23 +496,6 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
if ( bNewConnection ) if ( bNewConnection )
{ {
// if this is a new connection and the current network packet is
// neither an audio or protocol packet, we have to query the
// network transport properties for the audio packets
// (this is only required for server since we defined that the
// server has to send with the same properties as sent by
// the client)
// TODO check the conditions: !bIsProtocolPacket should always be true
// since we can only get here if bNewConnection, should we really put
// !bIsAudioPacket in here, because shouldn't we always query the audio
// properties on a new connection?
if ( bIsServer && ( !bIsProtocolPacket ) && ( !bIsAudioPacket ) )
{
Protocol.CreateReqNetwTranspPropsMes();
}
// inform other objects that new connection was established // inform other objects that new connection was established
emit NewConnection(); emit NewConnection();
} }

View file

@ -137,6 +137,7 @@ Protocol.CreateChanNameMes ( ChInfo.strName );
Protocol.CreateJitBufMes ( iJitBufSize ); Protocol.CreateJitBufMes ( iJitBufSize );
} }
} }
void CreateReqNetwTranspPropsMes() { Protocol.CreateReqNetwTranspPropsMes(); }
void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); } void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); }
void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); } void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); }
void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); } void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); }

View file

@ -514,6 +514,21 @@ void CServer::OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage )
Socket.SendPacket ( vecMessage, vecChannels[iChID].GetAddress() ); Socket.SendPacket ( vecMessage, vecChannels[iChID].GetAddress() );
} }
void CServer::OnNewConnection ( int iChID )
{
// on a new connection we query the network transport properties for the
// audio packets (to use the correct network block size and audio
// compression properties, etc.)
vecChannels[iChID].CreateReqNetwTranspPropsMes();
// this is a new connection, query the jitter buffer size we shall use
// for this client (note that at the same time on a new connection the
// client sends the jitter buffer size by default but maybe we have
// reached a state where this did not happen because of network trouble,
// client or server thinks that the connection was still active, etc.)
vecChannels[iChID].CreateReqJitBufMes();
}
void CServer::OnSendCLProtMessage ( CHostAddress InetAddr, void CServer::OnSendCLProtMessage ( CHostAddress InetAddr,
CVector<uint8_t> vecMessage ) CVector<uint8_t> vecMessage )
{ {

View file

@ -262,6 +262,7 @@ signals:
public slots: public slots:
void OnTimer(); void OnTimer();
void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage ); void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage );
void OnNewConnection ( int iChID );
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage ); void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnDetCLMess ( const CVector<uint8_t>& vecbyData, void OnDetCLMess ( const CVector<uint8_t>& vecbyData,
@ -337,18 +338,18 @@ public slots:
void OnDetCLMessCh10 ( CVector<uint8_t> vData, int iNBy ) { OnDetCLMess ( vData, iNBy, vecChannels[10].GetAddress() ); } void OnDetCLMessCh10 ( CVector<uint8_t> vData, int iNBy ) { OnDetCLMess ( vData, iNBy, vecChannels[10].GetAddress() ); }
void OnDetCLMessCh11 ( CVector<uint8_t> vData, int iNBy ) { OnDetCLMess ( vData, iNBy, vecChannels[11].GetAddress() ); } void OnDetCLMessCh11 ( CVector<uint8_t> vData, int iNBy ) { OnDetCLMess ( vData, iNBy, vecChannels[11].GetAddress() ); }
void OnNewConnectionCh0() { vecChannels[0].CreateReqJitBufMes(); } void OnNewConnectionCh0() { OnNewConnection ( 0 ); }
void OnNewConnectionCh1() { vecChannels[1].CreateReqJitBufMes(); } void OnNewConnectionCh1() { OnNewConnection ( 1 ); }
void OnNewConnectionCh2() { vecChannels[2].CreateReqJitBufMes(); } void OnNewConnectionCh2() { OnNewConnection ( 2 ); }
void OnNewConnectionCh3() { vecChannels[3].CreateReqJitBufMes(); } void OnNewConnectionCh3() { OnNewConnection ( 3 ); }
void OnNewConnectionCh4() { vecChannels[4].CreateReqJitBufMes(); } void OnNewConnectionCh4() { OnNewConnection ( 4 ); }
void OnNewConnectionCh5() { vecChannels[5].CreateReqJitBufMes(); } void OnNewConnectionCh5() { OnNewConnection ( 5 ); }
void OnNewConnectionCh6() { vecChannels[6].CreateReqJitBufMes(); } void OnNewConnectionCh6() { OnNewConnection ( 6 ); }
void OnNewConnectionCh7() { vecChannels[7].CreateReqJitBufMes(); } void OnNewConnectionCh7() { OnNewConnection ( 7 ); }
void OnNewConnectionCh8() { vecChannels[8].CreateReqJitBufMes(); } void OnNewConnectionCh8() { OnNewConnection ( 8 ); }
void OnNewConnectionCh9() { vecChannels[9].CreateReqJitBufMes(); } void OnNewConnectionCh9() { OnNewConnection ( 9 ); }
void OnNewConnectionCh10() { vecChannels[10].CreateReqJitBufMes(); } void OnNewConnectionCh10() { OnNewConnection ( 10 ); }
void OnNewConnectionCh11() { vecChannels[11].CreateReqJitBufMes(); } void OnNewConnectionCh11() { OnNewConnection ( 11 ); }
void OnReqConnClientsListCh0() { CreateAndSendChanListForThisChan ( 0 ); } void OnReqConnClientsListCh0() { CreateAndSendChanListForThisChan ( 0 ); }
void OnReqConnClientsListCh1() { CreateAndSendChanListForThisChan ( 1 ); } void OnReqConnClientsListCh1() { CreateAndSendChanListForThisChan ( 1 ); }