some more work for connection less protocl mechanism
This commit is contained in:
parent
e5d868fe20
commit
8926dec08b
10 changed files with 81 additions and 15 deletions
|
@ -25,7 +25,7 @@
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
|
|
||||||
|
|
||||||
/* Implementation *************************************************************/
|
// CChannel implementation *****************************************************
|
||||||
CChannel::CChannel ( const bool bNIsServer ) :
|
CChannel::CChannel ( const bool bNIsServer ) :
|
||||||
bIsServer ( bNIsServer ),
|
bIsServer ( bNIsServer ),
|
||||||
vecdGains ( USED_NUM_CHANNELS, (double) 1.0 ),
|
vecdGains ( USED_NUM_CHANNELS, (double) 1.0 ),
|
||||||
|
@ -546,3 +546,10 @@ int CChannel::GetUploadRateKbps()
|
||||||
8 /* bits per byte */ *
|
8 /* bits per byte */ *
|
||||||
SYSTEM_SAMPLE_RATE / iAudioSizeOut / 1000;
|
SYSTEM_SAMPLE_RATE / iAudioSizeOut / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CConnectionLessChannel implementation ***************************************
|
||||||
|
CConnectionLessChannel::CConnectionLessChannel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ public:
|
||||||
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 ); }
|
||||||
void CreatePingMes ( const int iMs ) { Protocol.CreatePingMes ( iMs ); }
|
void CreatePingMes ( const int iMs ) { Protocol.CreatePingMes ( iMs, false ); }
|
||||||
|
|
||||||
void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo )
|
void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo )
|
||||||
{
|
{
|
||||||
|
@ -190,4 +190,25 @@ signals:
|
||||||
void Disconnected();
|
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_ ) */
|
#endif /* !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */
|
||||||
|
|
|
@ -287,6 +287,19 @@ void CProtocol::CreateAndImmSendAcknMess ( const int& iID,
|
||||||
emit MessReadyForSending ( vecAcknMessage );
|
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,
|
bool CProtocol::IsProtocolMessage ( const CVector<uint8_t>& vecbyData,
|
||||||
const int iNumBytes )
|
const int iNumBytes )
|
||||||
{
|
{
|
||||||
|
@ -296,7 +309,11 @@ bool CProtocol::IsProtocolMessage ( const CVector<uint8_t>& vecbyData,
|
||||||
int iRecCounter, iRecID;
|
int iRecCounter, iRecID;
|
||||||
CVector<uint8_t> vecData;
|
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,
|
bool CProtocol::ParseMessage ( const CVector<uint8_t>& vecbyData,
|
||||||
|
@ -789,7 +806,8 @@ bool CProtocol::EvaluateChatTextMes ( const CVector<uint8_t>& vecData )
|
||||||
return false; // no error
|
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
|
unsigned int iPos = 0; // init position pointer
|
||||||
|
|
||||||
|
@ -799,8 +817,16 @@ void CProtocol::CreatePingMes ( const int iMs )
|
||||||
// byte-by-byte copying of the string data
|
// byte-by-byte copying of the string data
|
||||||
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iMs ), 4 );
|
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iMs ), 4 );
|
||||||
|
|
||||||
|
// distinguish between connection less and with connection transmission
|
||||||
|
if ( bIsConnectionLess )
|
||||||
|
{
|
||||||
|
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_PING_MS, vecData );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CreateAndSendMessage ( PROTMESSID_PING_MS, vecData );
|
CreateAndSendMessage ( PROTMESSID_PING_MS, vecData );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CProtocol::EvaluatePingMes ( const CVector<uint8_t>& vecData )
|
bool CProtocol::EvaluatePingMes ( const CVector<uint8_t>& vecData )
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,10 +53,8 @@
|
||||||
#define PROTMESSID_DISCONNECTION 22 // disconnection
|
#define PROTMESSID_DISCONNECTION 22 // disconnection
|
||||||
#define PROTMESSID_REQ_CHANNEL_NAME 23 // request channel name for fader tag
|
#define PROTMESSID_REQ_CHANNEL_NAME 23 // request channel name for fader tag
|
||||||
|
|
||||||
// message IDs of connection less messages (CLM) -> start at 1000
|
// message IDs of connection less messages (CLM)
|
||||||
|
// DEFINITION -> start at 1000, end at 1999
|
||||||
// TODO implementation of the messages...
|
|
||||||
|
|
||||||
#define PROTMESSID_CLM_PING_MS 1001 // for measuring ping time
|
#define PROTMESSID_CLM_PING_MS 1001 // for measuring ping time
|
||||||
#define PROTMESSID_CLM_SERVER_FULL 1002 // server full message
|
#define PROTMESSID_CLM_SERVER_FULL 1002 // server full message
|
||||||
#define PROTMESSID_CLM_SERVER_LIST 1003 // server list
|
#define PROTMESSID_CLM_SERVER_LIST 1003 // server list
|
||||||
|
@ -67,8 +65,6 @@
|
||||||
#define PROTMESSID_CLM_UNREGISTER_SERVER 1008 // unregister server
|
#define PROTMESSID_CLM_UNREGISTER_SERVER 1008 // unregister server
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// lengths of message as defined in protocol.cpp file
|
// 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_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) */ )
|
#define MESS_LEN_WITHOUT_DATA_BYTE ( MESS_HEADER_LENGTH_BYTE + 2 /* CRC (2) */ )
|
||||||
|
@ -96,7 +92,7 @@ public:
|
||||||
void CreateChanNameMes ( const QString strName );
|
void CreateChanNameMes ( const QString strName );
|
||||||
void CreateReqChanNameMes();
|
void CreateReqChanNameMes();
|
||||||
void CreateChatTextMes ( const QString strChatText );
|
void CreateChatTextMes ( const QString strChatText );
|
||||||
void CreatePingMes ( const int iMs );
|
void CreatePingMes ( const int iMs, const bool bIsConnectionLess );
|
||||||
void CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps );
|
void CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps );
|
||||||
void CreateReqNetwTranspPropsMes();
|
void CreateReqNetwTranspPropsMes();
|
||||||
|
|
||||||
|
@ -161,6 +157,9 @@ protected:
|
||||||
|
|
||||||
void CreateAndSendMessage ( const int iID, const CVector<uint8_t>& vecData );
|
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 EvaluateJitBufMes ( const CVector<uint8_t>& vecData );
|
||||||
bool EvaluateReqJitBufMes();
|
bool EvaluateReqJitBufMes();
|
||||||
bool EvaluateChanGainMes ( const CVector<uint8_t>& vecData );
|
bool EvaluateChanGainMes ( const CVector<uint8_t>& vecData );
|
||||||
|
|
|
@ -861,6 +861,12 @@ bool CServer::PutData ( const CVector<uint8_t>& vecbyRecBuf,
|
||||||
|
|
||||||
if ( iCurChanID == INVALID_CHANNEL_ID )
|
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
|
// a new client is calling, look for free channel
|
||||||
iCurChanID = GetFreeChan();
|
iCurChanID = GetFreeChan();
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,10 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CServerList : public QList<CServerListProperties>
|
class CServerList : public QList<CServerListProperties>//, public QObject
|
||||||
{
|
{
|
||||||
|
// Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CServerList() {}
|
CServerList() {}
|
||||||
virtual ~CServerList() {}
|
virtual ~CServerList() {}
|
||||||
|
|
|
@ -36,7 +36,7 @@ CHistoryGraph::CHistoryGraph() :
|
||||||
iYAxisEnd ( 24 ),
|
iYAxisEnd ( 24 ),
|
||||||
iNumTicksY ( 5 ),
|
iNumTicksY ( 5 ),
|
||||||
iGridFrameOffset ( 10 ),
|
iGridFrameOffset ( 10 ),
|
||||||
iGridWidthWeekend ( 3 ), // should be odd value
|
iGridWidthWeekend ( 3 ), // should be an odd value
|
||||||
iTextOffsetToGrid ( 3 ),
|
iTextOffsetToGrid ( 3 ),
|
||||||
iXAxisTextHeight ( 22 ),
|
iXAxisTextHeight ( 22 ),
|
||||||
iMarkerSizeNewCon ( 11 ),
|
iMarkerSizeNewCon ( 11 ),
|
||||||
|
|
|
@ -109,7 +109,7 @@ public slots:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
Protocol.CreatePingMes ( GenRandomIntInRange ( 0, 100000 ) );
|
Protocol.CreatePingMes ( GenRandomIntInRange ( 0, 100000 ), false );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
|
|
|
@ -44,6 +44,7 @@ rem .h --------------
|
||||||
%qtdir%\bin\moc.exe ..\src\testbench.h -o moc\moc_testbench.cpp
|
%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\serverlogging.h -o moc\moc_serverlogging.cpp
|
||||||
%qtdir%\bin\moc.exe ..\src\vstmain.h -o moc\moc_vstmain.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 -------------
|
rem .ui -------------
|
||||||
|
|
|
@ -1113,6 +1113,10 @@
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\moc\moc_serverlist.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\moc\moc_serverlogging.cpp"
|
RelativePath=".\moc\moc_serverlogging.cpp"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue