Skip to content

Commit f00dd05

Browse files
authored
Merge pull request #3727 from dingodoppelt/feature-set-cl-message
Server Features CL Message
2 parents 450238f + 12b54f4 commit f00dd05

6 files changed

Lines changed: 119 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_FEATURES: Bitmask of enabled server features
465+
466+
+------------------+
467+
| 4 bytes number n |
468+
+------------------+
469+
470+
471+
- PROTMESSID_CLM_REQ_SERVER_FEATURES: 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_FEATURES:
965+
EvaluateCLReqServerFeaturesMes ( 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::EvaluateCLReqServerFeaturesMes ( const CHostAddress& InetAddr )
2641+
{
2642+
// invoke message action
2643+
emit CLReqServerFeatures ( InetAddr );
2644+
2645+
return false; // no error
2646+
}
2647+
2648+
void CProtocol::CreateCLServerFeaturesMes ( const CHostAddress& InetAddr, const uint32_t iFeatures )
2649+
{
2650+
int iPos = 0; // init position pointer
2651+
CVector<uint8_t> vecData ( 4 );
2652+
2653+
PutValOnStream ( vecData, iPos, iFeatures, 4 );
2654+
2655+
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_FEATURES, 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_FEATURES 1019 // server features message
110+
#define PROTMESSID_CLM_REQ_SERVER_FEATURES 1020 // request server features
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 CreateCLServerFeaturesMes ( 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 EvaluateCLReqServerFeaturesMes ( 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 CLReqServerFeatures ( CHostAddress InetAddr );
374379
};

src/server.cpp

Lines changed: 57 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::CLReqServerFeatures, this, &CServer::OnCLReqServerFeatures );
296+
294297
QObject::connect ( &ServerListManager, &CServerListManager::SvrRegStatusChanged, this, &CServer::SvrRegStatusChanged );
295298

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

478+
void CServer::OnCLReqServerFeatures ( CHostAddress RecHostAddr )
479+
{
480+
// This is a bitmask of features enabled at the server.
481+
// EFeatureSet from util.h is used to shift each bool into position
482+
uint32_t iFeatures = 0;
483+
484+
// Use 64 samples frame size mode? (argument -F)
485+
iFeatures |= ( !bUseDoubleSystemFrameSize << FS_FAST_UPDATE );
486+
487+
// Multithreading enabled? (argument -T)
488+
iFeatures |= ( bUseMultithreading << FS_MULTITHREADING );
489+
490+
// Recording directory set? (argument -R)
491+
// If a recording directory is set a server could potentially record all client audio
492+
iFeatures |= ( GetRecorderInitialised() << FS_RECORDER_ENABLED );
493+
494+
// Will an idle server start recording when a client joins or is it already recording an active session?
495+
// (argument --norecord disables recording by default)
496+
iFeatures |= ( ( JamController.GetRecorderState() == RS_RECORDING ) << FS_IS_RECORDING );
497+
498+
// Delay pan enabled? (argument -P)
499+
iFeatures |= ( bDelayPan << FS_DELAY_PAN );
500+
501+
// IPv6 available? (argument --noipv6 disables this feature)
502+
iFeatures |= ( bIPv6Available << FS_IPV6_AVAILABLE );
503+
504+
// "Max" audio quality setting enabled? (argument --noraw disables this feature)
505+
iFeatures |= ( !bDisableRaw << FS_RAW_AUDIO );
506+
507+
// Disconnect all clients on quit? (argument -d)
508+
iFeatures |= ( bDisconnectAllClientsOnQuit << FS_DISCONONQUIT );
509+
510+
// Has welcome message? (argument -w)
511+
iFeatures |= ( !strWelcomeMessage.isEmpty() << FS_HAS_WELCOME_MESSAGE );
512+
513+
// Logging enabled? (argument -l)
514+
iFeatures |= ( Logging.IsLogging() << FS_IS_LOGGING );
515+
516+
// Licence agreement required? (argument -L)
517+
iFeatures |= ( ( eLicenceType != LT_NO_LICENCE ) << FS_HAS_LICENCE );
518+
519+
// TODO:
520+
// Running a GUI? (argument -n disables the GUI)
521+
// iFeatures |= ( << FS_HAS_GUI );
522+
//
523+
// // RPC interface enabled? (argument --jsonrpcport)
524+
// iFeatures |= ( << FS_RPC_ENABLED );
525+
526+
// qDebug() << QString::number(iFeatures, 2).rightJustified(32, '0');
527+
528+
// Create and send the message
529+
ConnLessProtocol.CreateCLServerFeaturesMes ( RecHostAddr, iFeatures );
530+
}
531+
475532
void CServer::OnServerFull ( CHostAddress RecHostAddr )
476533
{
477534
// 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 OnCLReqServerFeatures ( CHostAddress InetAddr );
400+
399401
void OnCLDisconnection ( CHostAddress InetAddr );
400402

401403
void OnAboutToQuit();

src/serverlogging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class CServerLogging
6666
void AddServerStopped();
6767

6868
void AddNewConnection ( const QHostAddress& ClientInetAddr, const int iNumberOfConnectedClients );
69+
bool IsLogging() { return bDoLogging; }
6970

7071
protected:
7172
void operator<< ( const QString& sNewStr );

src/util.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,25 @@ enum EDirectoryType
617617
AT_CUSTOM = 7 // Must be the last entry!
618618
};
619619

620+
// Server feature set ----------------------------------------------------------
621+
enum EFeatureSet
622+
{
623+
// used for protocol -> enum values must be fixed
624+
FS_FAST_UPDATE = 0,
625+
FS_MULTITHREADING = 1,
626+
FS_RECORDER_ENABLED = 2,
627+
FS_IS_RECORDING = 3,
628+
FS_DELAY_PAN = 4,
629+
FS_IPV6_AVAILABLE = 5,
630+
FS_RAW_AUDIO = 6,
631+
FS_DISCONONQUIT = 7,
632+
FS_HAS_WELCOME_MESSAGE = 8,
633+
FS_IS_LOGGING = 9,
634+
FS_HAS_LICENCE = 10,
635+
FS_HAS_GUI = 11,
636+
FS_RPC_ENABLED = 12
637+
};
638+
620639
inline QString DirectoryTypeToString ( EDirectoryType eAddrType )
621640
{
622641
switch ( eAddrType )

0 commit comments

Comments
 (0)