diff --git a/src/channel.cpp b/src/channel.cpp index 16b6a1d0..de606c6f 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -356,6 +356,21 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, bIsProtocolPacket = true; } } + else + { + // In case we are the server and the current channel is not + // connected, we do not evaluate protocal messages but these + // messages could start the server which is not desired, especially + // not for the disconnect messages. + // We now do not start the server if a valid protocol message + // was received but only start the server on audio packets + if ( Protocol.IsProtocolMessage ( vecbyData, iNumBytes ) ) + { + // set status flags + eRet = PS_PROT_OK_MESS_NOT_EVALUATED; + bIsProtocolPacket = true; + } + } // only try to parse audio if it was not a protocol packet if ( !bIsProtocolPacket ) @@ -421,6 +436,12 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, // (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 quere the audio +// properties on a new connection? + if ( bIsServer && ( !bIsProtocolPacket ) && ( !bIsAudioPacket ) ) { Protocol.CreateReqNetwTranspPropsMes(); diff --git a/src/channel.h b/src/channel.h index 4c16cba5..5361566d 100755 --- a/src/channel.h +++ b/src/channel.h @@ -47,6 +47,7 @@ enum EPutDataStat PS_AUDIO_OK, PS_AUDIO_ERR, PS_PROT_OK, + PS_PROT_OK_MESS_NOT_EVALUATED, PS_PROT_ERR }; diff --git a/src/protocol.cpp b/src/protocol.cpp index db4bbc78..ffca1908 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -287,6 +287,18 @@ void CProtocol::CreateAndImmSendAcknMess ( const int& iID, emit MessReadyForSending ( vecAcknMessage ); } +bool CProtocol::IsProtocolMessage ( const CVector& vecbyData, + const int iNumBytes ) +{ +/* + just check if this is a protocol message but do not act on message +*/ + int iRecCounter, iRecID; + CVector vecData; + + return !ParseMessageFrame ( vecbyData, iNumBytes, iRecCounter, iRecID, vecData ); +} + bool CProtocol::ParseMessage ( const CVector& vecbyData, const int iNumBytes ) { @@ -973,9 +985,6 @@ bool CProtocol::ParseMessageFrame ( const CVector& vecIn, int& iID, CVector& vecData ) { -/* - return code: true -> ok; false -> error -*/ int iLenBy, i; unsigned int iCurPos; diff --git a/src/protocol.h b/src/protocol.h index d398efcf..2344f81c 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -88,7 +88,10 @@ public: void CreateAndImmSendAcknMess ( const int& iID, const int& iCnt ); bool ParseMessage ( const CVector& vecbyData, - const int iNumBytes ); + const int iNumBytes ); + + bool IsProtocolMessage ( const CVector& vecbyData, + const int iNumBytes ); protected: class CSendMessage diff --git a/src/server.cpp b/src/server.cpp index d8368925..47630864 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -621,8 +621,9 @@ bool CServer::PutData ( const CVector& vecbyRecBuf, const int iNumBytesRead, const CHostAddress& HostAdr ) { - bool bChanOK = true; // init with ok, might be overwritten - bool bNewChannelReserved = false; + bool bChanOK = true; // init with ok, might be overwritten + bool bNewChannelReserved = false; + bool bIsNotEvaluatedProtocolMessage = false; Mutex.lock(); { @@ -688,11 +689,15 @@ bool CServer::PutData ( const CVector& vecbyRecBuf, case PS_PROT_ERR: PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW, iCurChanID ); break; + + case PS_PROT_OK_MESS_NOT_EVALUATED: + bIsNotEvaluatedProtocolMessage = true; // set flag + break; } } // act on new channel connection - if ( bNewChannelReserved ) + if ( bNewChannelReserved && ( !bIsNotEvaluatedProtocolMessage ) ) { // logging of new connected channel Logging.AddNewConnection ( HostAdr.InetAddr );