Skip to content

Commit 87e7c7a

Browse files
committed
Add connection-less message to query enabled server features
1 parent 76fc757 commit 87e7c7a

4 files changed

Lines changed: 61 additions & 0 deletions

File tree

src/protocol.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,19 @@ CONNECTION LESS MESSAGES
459459
five times for one registration request at 500ms intervals.
460460
Beyond this, it should "ping" every 15 minutes
461461
(standard re-registration timeout).
462+
463+
464+
- PROTMESSID_CLM_SERVER_INFO: Bitmask of enabled server features
465+
466+
+------------------+
467+
| 4 bytes number n |
468+
+------------------+
469+
470+
471+
- PROTMESSID_CLM_REQ_SERVER_INFO: Request bitmask of enabled server features
472+
473+
note: does not have any data -> n = 0
474+
462475
*/
463476

464477
#include "protocol.h"
@@ -947,6 +960,10 @@ void CProtocol::ParseConnectionLessMessageBody ( const CVector<uint8_t>& vecbyMe
947960
case PROTMESSID_CLM_REGISTER_SERVER_RESP:
948961
EvaluateCLRegisterServerResp ( InetAddr, vecbyMesBodyData );
949962
break;
963+
964+
case PROTMESSID_CLM_REQ_SERVER_INFO:
965+
EvaluateCLReqServerInfoMes ( InetAddr );
966+
break;
950967
}
951968
}
952969

@@ -2620,6 +2637,24 @@ bool CProtocol::EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, con
26202637
return false; // no error
26212638
}
26222639

2640+
bool CProtocol::EvaluateCLReqServerInfoMes ( const CHostAddress& InetAddr )
2641+
{
2642+
// invoke message action
2643+
emit CLReqServerInfo ( InetAddr );
2644+
2645+
return false; // no error
2646+
}
2647+
2648+
void CProtocol::CreateCLServerInfoMes ( const CHostAddress& InetAddr, const uint32_t iFeatures )
2649+
{
2650+
int iPos = 0; // init position pointer
2651+
CVector<uint8_t> vecData ( 1 );
2652+
2653+
PutValOnStream ( vecData, iPos, iFeatures, 4 );
2654+
2655+
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_INFO, vecData, InetAddr );
2656+
}
2657+
26232658
/******************************************************************************\
26242659
* Message generation and parsing *
26252660
\******************************************************************************/

src/protocol.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
#define PROTMESSID_CLM_REGISTER_SERVER_RESP 1016 // status of server registration request
107107
#define PROTMESSID_CLM_REGISTER_SERVER_EX 1017 // register server with extended information
108108
#define PROTMESSID_CLM_RED_SERVER_LIST 1018 // reduced server list
109+
#define PROTMESSID_CLM_SERVER_INFO 1019 // server info message
110+
#define PROTMESSID_CLM_REQ_SERVER_INFO 1020 // request server info
109111

110112
// special IDs
111113
#define PROTMESSID_SPECIAL_SPLIT_MESSAGE 2001 // a container for split messages
@@ -177,6 +179,7 @@ class CProtocol : public QObject
177179
void CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr );
178180
void CreateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector<uint16_t>& vecLevelList, const int iNumClients );
179181
void CreateCLRegisterServerResp ( const CHostAddress& InetAddr, const ESvrRegResult eResult );
182+
void CreateCLServerInfoMes ( const CHostAddress& InetAddr, const uint32_t iResult );
180183

181184
static bool ParseMessageFrame ( const CVector<uint8_t>& vecbyData,
182185
const int iNumBytesIn,
@@ -304,6 +307,7 @@ class CProtocol : public QObject
304307
bool EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr );
305308
bool EvaluateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData );
306309
bool EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData );
310+
bool EvaluateCLReqServerInfoMes ( const CHostAddress& InetAddr );
307311

308312
int iOldRecID;
309313
int iOldRecCnt;
@@ -371,4 +375,5 @@ public slots:
371375
void CLReqConnClientsList ( CHostAddress InetAddr );
372376
void CLChannelLevelListReceived ( CHostAddress InetAddr, CVector<uint16_t> vecLevelList );
373377
void CLRegisterServerResp ( CHostAddress InetAddr, ESvrRegResult eStatus );
378+
void CLReqServerInfo ( CHostAddress InetAddr );
374379
};

src/server.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
\******************************************************************************/
4646

4747
#include "server.h"
48+
#include "util.h"
4849

4950
// CServer implementation ******************************************************
5051
CServer::CServer ( const int iNewMaxNumChan,
@@ -291,6 +292,8 @@ CServer::CServer ( const int iNewMaxNumChan,
291292

292293
QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqConnClientsList, this, &CServer::OnCLReqConnClientsList );
293294

295+
QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqServerInfo, this, &CServer::OnCLReqServerInfo );
296+
294297
QObject::connect ( &ServerListManager, &CServerListManager::SvrRegStatusChanged, this, &CServer::SvrRegStatusChanged );
295298

296299
QObject::connect ( &JamController, &recorder::CJamController::RestartRecorder, this, &CServer::RestartRecorder );
@@ -472,6 +475,22 @@ void CServer::OnNewConnection ( int iChID, int iTotChans, CHostAddress RecHostAd
472475
Logging.AddNewConnection ( RecHostAddr.InetAddr, iTotChans );
473476
}
474477

478+
void CServer::OnCLReqServerInfo ( CHostAddress RecHostAddr )
479+
{
480+
uint32_t iFeatures = 0;
481+
482+
iFeatures |= (bUseDoubleSystemFrameSize << 0);
483+
iFeatures |= (bUseMultithreading << 1);
484+
iFeatures |= (GetRecorderInitialised() << 2);
485+
iFeatures |= (GetDisableRecording() << 3);
486+
iFeatures |= ((JamController.GetRecorderState() != RS_RECORDING) << 4);
487+
iFeatures |= (bDelayPan << 5);
488+
iFeatures |= (bEnableIPv6 << 6);
489+
// iFeatures |= (bDisableRaw << 5);
490+
491+
ConnLessProtocol.CreateCLServerInfoMes ( RecHostAddr, iFeatures );
492+
}
493+
475494
void CServer::OnServerFull ( CHostAddress RecHostAddr )
476495
{
477496
// note: no mutex required here

src/server.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ public slots:
396396

397397
void OnCLUnregisterServerReceived ( CHostAddress InetAddr ) { ServerListManager.Remove ( InetAddr ); }
398398

399+
void OnCLReqServerInfo ( CHostAddress InetAddr );
400+
399401
void OnCLDisconnection ( CHostAddress InetAddr );
400402

401403
void OnAboutToQuit();

0 commit comments

Comments
 (0)