diff --git a/src/protocol.cpp b/src/protocol.cpp index a30534bc72..baab5c9bb4 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -437,6 +437,19 @@ CONNECTION LESS MESSAGES five times for one registration request at 500ms intervals. Beyond this, it should "ping" every 15 minutes (standard re-registration timeout). + + +- PROTMESSID_CLM_SERVER_INFO: Bitmask of enabled server features + + +------------------+ + | 4 bytes number n | + +------------------+ + + +- PROTMESSID_CLM_REQ_SERVER_INFO: Request bitmask of enabled server features + + note: does not have any data -> n = 0 + */ #include "protocol.h" @@ -925,6 +938,10 @@ void CProtocol::ParseConnectionLessMessageBody ( const CVector& vecbyMe case PROTMESSID_CLM_REGISTER_SERVER_RESP: EvaluateCLRegisterServerResp ( InetAddr, vecbyMesBodyData ); break; + + case PROTMESSID_CLM_REQ_SERVER_INFO: + EvaluateCLReqServerInfoMes ( InetAddr ); + break; } } @@ -2598,6 +2615,24 @@ bool CProtocol::EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, con return false; // no error } +bool CProtocol::EvaluateCLReqServerInfoMes ( const CHostAddress& InetAddr ) +{ + // invoke message action + emit CLReqServerInfo ( InetAddr ); + + return false; // no error +} + +void CProtocol::CreateCLServerInfoMes ( const CHostAddress& InetAddr, const uint32_t iFeatures ) +{ + int iPos = 0; // init position pointer + CVector vecData ( 1 ); + + PutValOnStream ( vecData, iPos, iFeatures, 4 ); + + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_INFO, vecData, InetAddr ); +} + /******************************************************************************\ * Message generation and parsing * \******************************************************************************/ diff --git a/src/protocol.h b/src/protocol.h index 03ac9f328f..6f24c32ed6 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -84,6 +84,8 @@ #define PROTMESSID_CLM_REGISTER_SERVER_RESP 1016 // status of server registration request #define PROTMESSID_CLM_REGISTER_SERVER_EX 1017 // register server with extended information #define PROTMESSID_CLM_RED_SERVER_LIST 1018 // reduced server list +#define PROTMESSID_CLM_SERVER_INFO 1019 // server info message +#define PROTMESSID_CLM_REQ_SERVER_INFO 1020 // request server info // special IDs #define PROTMESSID_SPECIAL_SPLIT_MESSAGE 2001 // a container for split messages @@ -155,6 +157,7 @@ class CProtocol : public QObject void CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr ); void CreateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector& vecLevelList, const int iNumClients ); void CreateCLRegisterServerResp ( const CHostAddress& InetAddr, const ESvrRegResult eResult ); + void CreateCLServerInfoMes ( const CHostAddress& InetAddr, const uint32_t iResult ); static bool ParseMessageFrame ( const CVector& vecbyData, const int iNumBytesIn, @@ -282,6 +285,7 @@ class CProtocol : public QObject bool EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr ); bool EvaluateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector& vecData ); bool EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, const CVector& vecData ); + bool EvaluateCLReqServerInfoMes ( const CHostAddress& InetAddr ); int iOldRecID; int iOldRecCnt; @@ -349,4 +353,5 @@ public slots: void CLReqConnClientsList ( CHostAddress InetAddr ); void CLChannelLevelListReceived ( CHostAddress InetAddr, CVector vecLevelList ); void CLRegisterServerResp ( CHostAddress InetAddr, ESvrRegResult eStatus ); + void CLReqServerInfo ( CHostAddress InetAddr ); }; diff --git a/src/server.cpp b/src/server.cpp index 76d0e98bc7..c8abf95a48 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -23,6 +23,7 @@ \******************************************************************************/ #include "server.h" +#include "util.h" // CServer implementation ****************************************************** CServer::CServer ( const int iNewMaxNumChan, @@ -269,6 +270,8 @@ CServer::CServer ( const int iNewMaxNumChan, QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqConnClientsList, this, &CServer::OnCLReqConnClientsList ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqServerInfo, this, &CServer::OnCLReqServerInfo ); + QObject::connect ( &ServerListManager, &CServerListManager::SvrRegStatusChanged, this, &CServer::SvrRegStatusChanged ); QObject::connect ( &JamController, &recorder::CJamController::RestartRecorder, this, &CServer::RestartRecorder ); @@ -450,6 +453,22 @@ void CServer::OnNewConnection ( int iChID, int iTotChans, CHostAddress RecHostAd Logging.AddNewConnection ( RecHostAddr.InetAddr, iTotChans ); } +void CServer::OnCLReqServerInfo ( CHostAddress RecHostAddr ) +{ + uint32_t iFeatures = 0; + + iFeatures |= ( !bUseDoubleSystemFrameSize << FS_SMALL_NETW_BUF ); + iFeatures |= ( bUseMultithreading << FS_MULTITHREADING ); + iFeatures |= ( GetRecorderInitialised() << FS_RECORDER_INIT ); + iFeatures |= ( GetDisableRecording() << FS_DISABLE_RECORDING ); + iFeatures |= ( (JamController.GetRecorderState() != RS_RECORDING) << FS_IS_RECORDING ); + iFeatures |= ( bDelayPan << FS_DELAY_PAN ); + iFeatures |= ( bEnableIPv6 << FS_ENABLE_IPV6 ); + // iFeatures |= ( bDisableRaw << FS_RAW_AUDIO ); + + ConnLessProtocol.CreateCLServerInfoMes ( RecHostAddr, iFeatures ); +} + void CServer::OnServerFull ( CHostAddress RecHostAddr ) { // note: no mutex required here diff --git a/src/server.h b/src/server.h index b159064c5a..0ac2ebb7fa 100644 --- a/src/server.h +++ b/src/server.h @@ -376,6 +376,8 @@ public slots: void OnCLUnregisterServerReceived ( CHostAddress InetAddr ) { ServerListManager.Remove ( InetAddr ); } + void OnCLReqServerInfo ( CHostAddress InetAddr ); + void OnCLDisconnection ( CHostAddress InetAddr ); void OnAboutToQuit(); diff --git a/src/util.h b/src/util.h index 04bf94b0e9..44ae3ab92d 100644 --- a/src/util.h +++ b/src/util.h @@ -591,6 +591,20 @@ enum EDirectoryType AT_CUSTOM = 7 // Must be the last entry! }; +// Server feature set ---------------------------------------------------------- +enum EFeatureSet +{ + // used for protocol -> enum values must be fixed + FS_SMALL_NETW_BUF = 0, + FS_MULTITHREADING = 1, + FS_RECORDER_INIT = 2, + FS_DISABLE_RECORDING = 3, + FS_IS_RECORDING = 4, + FS_DELAY_PAN = 5, + FS_ENABLE_IPV6 = 6, + FS_RAW_AUDIO = 7 +}; + inline QString DirectoryTypeToString ( EDirectoryType eAddrType ) { switch ( eAddrType )