some more work for connection less protocl mechanism

This commit is contained in:
Volker Fischer 2011-03-27 08:56:24 +00:00
parent e5d868fe20
commit 8926dec08b
10 changed files with 81 additions and 15 deletions

View File

@ -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()
{
}

View File

@ -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<CChannelShortInfo>& 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_ ) */

View File

@ -287,6 +287,19 @@ void CProtocol::CreateAndImmSendAcknMess ( const int& iID,
emit MessReadyForSending ( vecAcknMessage );
}
void CProtocol::CreateAndImmSendConLessMessage ( const int iID,
const CVector<uint8_t>& vecData )
{
CVector<uint8_t> 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<uint8_t>& vecbyData,
const int iNumBytes )
{
@ -296,7 +309,11 @@ bool CProtocol::IsProtocolMessage ( const CVector<uint8_t>& vecbyData,
int iRecCounter, iRecID;
CVector<uint8_t> vecData;
return !ParseMessageFrame ( vecbyData, iNumBytes, iRecCounter, iRecID, vecData );
return !ParseMessageFrame ( vecbyData,
iNumBytes,
iRecCounter,
iRecID,
vecData );
}
bool CProtocol::ParseMessage ( const CVector<uint8_t>& vecbyData,
@ -789,7 +806,8 @@ bool CProtocol::EvaluateChatTextMes ( const CVector<uint8_t>& 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<uint32_t> ( 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<uint8_t>& vecData )

View File

@ -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<uint8_t>& vecData );
void CreateAndImmSendConLessMessage ( const int iID,
const CVector<uint8_t>& vecData );
bool EvaluateJitBufMes ( const CVector<uint8_t>& vecData );
bool EvaluateReqJitBufMes();
bool EvaluateChanGainMes ( const CVector<uint8_t>& vecData );

View File

@ -861,6 +861,12 @@ bool CServer::PutData ( const CVector<uint8_t>& 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();

View File

@ -141,8 +141,10 @@ protected:
};
class CServerList : public QList<CServerListProperties>
class CServerList : public QList<CServerListProperties>//, public QObject
{
// Q_OBJECT
public:
CServerList() {}
virtual ~CServerList() {}

View File

@ -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 ),

View File

@ -109,7 +109,7 @@ public slots:
break;
case 7:
Protocol.CreatePingMes ( GenRandomIntInRange ( 0, 100000 ) );
Protocol.CreatePingMes ( GenRandomIntInRange ( 0, 100000 ), false );
break;
case 8:

View File

@ -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 -------------

View File

@ -1113,6 +1113,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\moc\moc_serverlist.cpp"
>
</File>
<File
RelativePath=".\moc\moc_serverlogging.cpp"
>