Skip to content

Commit 94ad42b

Browse files
committed
Add connection-less message to query enabled server features
1 parent 57f439f commit 94ad42b

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
@@ -437,6 +437,19 @@ CONNECTION LESS MESSAGES
437437
five times for one registration request at 500ms intervals.
438438
Beyond this, it should "ping" every 15 minutes
439439
(standard re-registration timeout).
440+
441+
442+
- PROTMESSID_CLM_SERVER_INFO: Bitmask of enabled server features
443+
444+
+------------------+
445+
| 4 bytes number n |
446+
+------------------+
447+
448+
449+
- PROTMESSID_CLM_REQ_SERVER_INFO: Request bitmask of enabled server features
450+
451+
note: does not have any data -> n = 0
452+
440453
*/
441454

442455
#include "protocol.h"
@@ -925,6 +938,10 @@ void CProtocol::ParseConnectionLessMessageBody ( const CVector<uint8_t>& vecbyMe
925938
case PROTMESSID_CLM_REGISTER_SERVER_RESP:
926939
EvaluateCLRegisterServerResp ( InetAddr, vecbyMesBodyData );
927940
break;
941+
942+
case PROTMESSID_CLM_REQ_SERVER_INFO:
943+
EvaluateCLReqServerInfoMes ( InetAddr );
944+
break;
928945
}
929946
}
930947

@@ -2598,6 +2615,24 @@ bool CProtocol::EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, con
25982615
return false; // no error
25992616
}
26002617

2618+
bool CProtocol::EvaluateCLReqServerInfoMes ( const CHostAddress& InetAddr )
2619+
{
2620+
// invoke message action
2621+
emit CLReqServerInfo ( InetAddr );
2622+
2623+
return false; // no error
2624+
}
2625+
2626+
void CProtocol::CreateCLServerInfoMes ( const CHostAddress& InetAddr, const uint32_t iFeatures )
2627+
{
2628+
int iPos = 0; // init position pointer
2629+
CVector<uint8_t> vecData ( 1 );
2630+
2631+
PutValOnStream ( vecData, iPos, iFeatures, 4 );
2632+
2633+
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_INFO, vecData, InetAddr );
2634+
}
2635+
26012636
/******************************************************************************\
26022637
* Message generation and parsing *
26032638
\******************************************************************************/

src/protocol.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@
8484
#define PROTMESSID_CLM_REGISTER_SERVER_RESP 1016 // status of server registration request
8585
#define PROTMESSID_CLM_REGISTER_SERVER_EX 1017 // register server with extended information
8686
#define PROTMESSID_CLM_RED_SERVER_LIST 1018 // reduced server list
87+
#define PROTMESSID_CLM_SERVER_INFO 1019 // server info message
88+
#define PROTMESSID_CLM_REQ_SERVER_INFO 1020 // request server info
8789

8890
// special IDs
8991
#define PROTMESSID_SPECIAL_SPLIT_MESSAGE 2001 // a container for split messages
@@ -155,6 +157,7 @@ class CProtocol : public QObject
155157
void CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr );
156158
void CreateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector<uint16_t>& vecLevelList, const int iNumClients );
157159
void CreateCLRegisterServerResp ( const CHostAddress& InetAddr, const ESvrRegResult eResult );
160+
void CreateCLServerInfoMes ( const CHostAddress& InetAddr, const uint32_t iResult );
158161

159162
static bool ParseMessageFrame ( const CVector<uint8_t>& vecbyData,
160163
const int iNumBytesIn,
@@ -282,6 +285,7 @@ class CProtocol : public QObject
282285
bool EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr );
283286
bool EvaluateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData );
284287
bool EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData );
288+
bool EvaluateCLReqServerInfoMes ( const CHostAddress& InetAddr );
285289

286290
int iOldRecID;
287291
int iOldRecCnt;
@@ -349,4 +353,5 @@ public slots:
349353
void CLReqConnClientsList ( CHostAddress InetAddr );
350354
void CLChannelLevelListReceived ( CHostAddress InetAddr, CVector<uint16_t> vecLevelList );
351355
void CLRegisterServerResp ( CHostAddress InetAddr, ESvrRegResult eStatus );
356+
void CLReqServerInfo ( CHostAddress InetAddr );
352357
};

src/server.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
\******************************************************************************/
2424

2525
#include "server.h"
26+
#include "util.h"
2627

2728
// CServer implementation ******************************************************
2829
CServer::CServer ( const int iNewMaxNumChan,
@@ -269,6 +270,8 @@ CServer::CServer ( const int iNewMaxNumChan,
269270

270271
QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqConnClientsList, this, &CServer::OnCLReqConnClientsList );
271272

273+
QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqServerInfo, this, &CServer::OnCLReqServerInfo );
274+
272275
QObject::connect ( &ServerListManager, &CServerListManager::SvrRegStatusChanged, this, &CServer::SvrRegStatusChanged );
273276

274277
QObject::connect ( &JamController, &recorder::CJamController::RestartRecorder, this, &CServer::RestartRecorder );
@@ -450,6 +453,22 @@ void CServer::OnNewConnection ( int iChID, int iTotChans, CHostAddress RecHostAd
450453
Logging.AddNewConnection ( RecHostAddr.InetAddr, iTotChans );
451454
}
452455

456+
void CServer::OnCLReqServerInfo ( CHostAddress RecHostAddr )
457+
{
458+
uint32_t iFeatures = 0;
459+
460+
iFeatures |= (bUseDoubleSystemFrameSize << 0);
461+
iFeatures |= (bUseMultithreading << 1);
462+
iFeatures |= (GetRecorderInitialised() << 2);
463+
iFeatures |= (GetDisableRecording() << 3);
464+
iFeatures |= ((JamController.GetRecorderState() != RS_RECORDING) << 4);
465+
iFeatures |= (bDelayPan << 5);
466+
iFeatures |= (bEnableIPv6 << 6);
467+
// iFeatures |= (bDisableRaw << 5);
468+
469+
ConnLessProtocol.CreateCLServerInfoMes ( RecHostAddr, iFeatures );
470+
}
471+
453472
void CServer::OnServerFull ( CHostAddress RecHostAddr )
454473
{
455474
// note: no mutex required here

src/server.h

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

377377
void OnCLUnregisterServerReceived ( CHostAddress InetAddr ) { ServerListManager.Remove ( InetAddr ); }
378378

379+
void OnCLReqServerInfo ( CHostAddress InetAddr );
380+
379381
void OnCLDisconnection ( CHostAddress InetAddr );
380382

381383
void OnAboutToQuit();

0 commit comments

Comments
 (0)