From 8926dec08b5b9449b1e7a5720792541c8feb5f9e Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 27 Mar 2011 08:56:24 +0000 Subject: [PATCH] some more work for connection less protocl mechanism --- src/channel.cpp | 9 ++++++++- src/channel.h | 23 ++++++++++++++++++++++- src/protocol.cpp | 32 +++++++++++++++++++++++++++++--- src/protocol.h | 13 ++++++------- src/server.cpp | 6 ++++++ src/serverlist.h | 4 +++- src/serverlogging.cpp | 2 +- src/testbench.h | 2 +- windows/MocQT.bat | 1 + windows/llcon.vcproj | 4 ++++ 10 files changed, 81 insertions(+), 15 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index cd8c3542..70a0eaef 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -25,7 +25,7 @@ #include "channel.h" -/* Implementation *************************************************************/ +// CChannel implementation ***************************************************** CChannel::CChannel ( const bool bNIsServer ) : bIsServer ( bNIsServer ), vecdGains ( USED_NUM_CHANNELS, (double) 1.0 ), @@ -546,3 +546,10 @@ int CChannel::GetUploadRateKbps() 8 /* bits per byte */ * SYSTEM_SAMPLE_RATE / iAudioSizeOut / 1000; } + + +// CConnectionLessChannel implementation *************************************** +CConnectionLessChannel::CConnectionLessChannel() +{ + +} diff --git a/src/channel.h b/src/channel.h index 5f78ed35..b6982892 100755 --- a/src/channel.h +++ b/src/channel.h @@ -119,7 +119,7 @@ public: void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); } void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); } void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); } - void CreatePingMes ( const int iMs ) { Protocol.CreatePingMes ( iMs ); } + void CreatePingMes ( const int iMs ) { Protocol.CreatePingMes ( iMs, false ); } void CreateConClientListMes ( const CVector& vecChanInfo ) { @@ -190,4 +190,25 @@ signals: void Disconnected(); }; + +class CConnectionLessChannel : public QObject +{ + Q_OBJECT + +public: + CConnectionLessChannel(); + virtual ~CConnectionLessChannel() {} + + void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; } + CHostAddress GetAddress() const { return InetAddr; } + +protected: + // connection parameters + CHostAddress InetAddr; + + // network protocol + CProtocol Protocol; +}; + + #endif /* !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */ diff --git a/src/protocol.cpp b/src/protocol.cpp index b262a765..b59b4a1e 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -287,6 +287,19 @@ void CProtocol::CreateAndImmSendAcknMess ( const int& iID, emit MessReadyForSending ( vecAcknMessage ); } +void CProtocol::CreateAndImmSendConLessMessage ( const int iID, + const CVector& vecData ) +{ + CVector vecNewMessage; + + // build complete message (counter per definition=0 for connection less + // messages) + GenMessageFrame ( vecNewMessage, 0, iID, vecData ); + + // immediately send message + emit MessReadyForSending ( vecNewMessage ); +} + bool CProtocol::IsProtocolMessage ( const CVector& vecbyData, const int iNumBytes ) { @@ -296,7 +309,11 @@ bool CProtocol::IsProtocolMessage ( const CVector& vecbyData, int iRecCounter, iRecID; CVector vecData; - return !ParseMessageFrame ( vecbyData, iNumBytes, iRecCounter, iRecID, vecData ); + return !ParseMessageFrame ( vecbyData, + iNumBytes, + iRecCounter, + iRecID, + vecData ); } bool CProtocol::ParseMessage ( const CVector& vecbyData, @@ -789,7 +806,8 @@ bool CProtocol::EvaluateChatTextMes ( const CVector& vecData ) return false; // no error } -void CProtocol::CreatePingMes ( const int iMs ) +void CProtocol::CreatePingMes ( const int iMs, + const bool bIsConnectionLess ) { unsigned int iPos = 0; // init position pointer @@ -799,7 +817,15 @@ void CProtocol::CreatePingMes ( const int iMs ) // byte-by-byte copying of the string data PutValOnStream ( vecData, iPos, static_cast ( iMs ), 4 ); - CreateAndSendMessage ( PROTMESSID_PING_MS, vecData ); + // distinguish between connection less and with connection transmission + if ( bIsConnectionLess ) + { + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_PING_MS, vecData ); + } + else + { + CreateAndSendMessage ( PROTMESSID_PING_MS, vecData ); + } } bool CProtocol::EvaluatePingMes ( const CVector& vecData ) diff --git a/src/protocol.h b/src/protocol.h index f9468e55..560572e8 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -53,10 +53,8 @@ #define PROTMESSID_DISCONNECTION 22 // disconnection #define PROTMESSID_REQ_CHANNEL_NAME 23 // request channel name for fader tag -// message IDs of connection less messages (CLM) -> start at 1000 - -// TODO implementation of the messages... - +// message IDs of connection less messages (CLM) +// DEFINITION -> start at 1000, end at 1999 #define PROTMESSID_CLM_PING_MS 1001 // for measuring ping time #define PROTMESSID_CLM_SERVER_FULL 1002 // server full message #define PROTMESSID_CLM_SERVER_LIST 1003 // server list @@ -67,8 +65,6 @@ #define PROTMESSID_CLM_UNREGISTER_SERVER 1008 // unregister server - - // lengths of message as defined in protocol.cpp file #define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2) #define MESS_LEN_WITHOUT_DATA_BYTE ( MESS_HEADER_LENGTH_BYTE + 2 /* CRC (2) */ ) @@ -96,7 +92,7 @@ public: void CreateChanNameMes ( const QString strName ); void CreateReqChanNameMes(); void CreateChatTextMes ( const QString strChatText ); - void CreatePingMes ( const int iMs ); + void CreatePingMes ( const int iMs, const bool bIsConnectionLess ); void CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps ); void CreateReqNetwTranspPropsMes(); @@ -161,6 +157,9 @@ protected: void CreateAndSendMessage ( const int iID, const CVector& vecData ); + void CreateAndImmSendConLessMessage ( const int iID, + const CVector& vecData ); + bool EvaluateJitBufMes ( const CVector& vecData ); bool EvaluateReqJitBufMes(); bool EvaluateChanGainMes ( const CVector& vecData ); diff --git a/src/server.cpp b/src/server.cpp index 67fe4621..e604ca96 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -861,6 +861,12 @@ bool CServer::PutData ( const CVector& vecbyRecBuf, if ( iCurChanID == INVALID_CHANNEL_ID ) { + + +// TODO at this point we have to check for connection less protocol messages! + + + // a new client is calling, look for free channel iCurChanID = GetFreeChan(); diff --git a/src/serverlist.h b/src/serverlist.h index bacf99b1..56bae9a6 100755 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -141,8 +141,10 @@ protected: }; -class CServerList : public QList +class CServerList : public QList//, public QObject { +// Q_OBJECT + public: CServerList() {} virtual ~CServerList() {} diff --git a/src/serverlogging.cpp b/src/serverlogging.cpp index c184410d..ae7619bf 100755 --- a/src/serverlogging.cpp +++ b/src/serverlogging.cpp @@ -36,7 +36,7 @@ CHistoryGraph::CHistoryGraph() : iYAxisEnd ( 24 ), iNumTicksY ( 5 ), iGridFrameOffset ( 10 ), - iGridWidthWeekend ( 3 ), // should be odd value + iGridWidthWeekend ( 3 ), // should be an odd value iTextOffsetToGrid ( 3 ), iXAxisTextHeight ( 22 ), iMarkerSizeNewCon ( 11 ), diff --git a/src/testbench.h b/src/testbench.h index a874250f..7f5e71b4 100755 --- a/src/testbench.h +++ b/src/testbench.h @@ -109,7 +109,7 @@ public slots: break; case 7: - Protocol.CreatePingMes ( GenRandomIntInRange ( 0, 100000 ) ); + Protocol.CreatePingMes ( GenRandomIntInRange ( 0, 100000 ), false ); break; case 8: diff --git a/windows/MocQT.bat b/windows/MocQT.bat index cc98ce3c..079ad604 100755 --- a/windows/MocQT.bat +++ b/windows/MocQT.bat @@ -44,6 +44,7 @@ rem .h -------------- %qtdir%\bin\moc.exe ..\src\testbench.h -o moc\moc_testbench.cpp %qtdir%\bin\moc.exe ..\src\serverlogging.h -o moc\moc_serverlogging.cpp %qtdir%\bin\moc.exe ..\src\vstmain.h -o moc\moc_vstmain.cpp +%qtdir%\bin\moc.exe ..\src\serverlist.h -o moc\moc_serverlist.cpp rem .ui ------------- diff --git a/windows/llcon.vcproj b/windows/llcon.vcproj index b73dcafd..a62af498 100755 --- a/windows/llcon.vcproj +++ b/windows/llcon.vcproj @@ -1113,6 +1113,10 @@ /> + +