Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,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_FEATURES: Bitmask of enabled server features

+------------------+
| 4 bytes number n |
+------------------+


- PROTMESSID_CLM_REQ_SERVER_FEATURES: Request bitmask of enabled server features

note: does not have any data -> n = 0

*/

#include "protocol.h"
Expand Down Expand Up @@ -947,6 +960,10 @@ void CProtocol::ParseConnectionLessMessageBody ( const CVector<uint8_t>& vecbyMe
case PROTMESSID_CLM_REGISTER_SERVER_RESP:
EvaluateCLRegisterServerResp ( InetAddr, vecbyMesBodyData );
break;

case PROTMESSID_CLM_REQ_SERVER_FEATURES:
EvaluateCLReqServerFeaturesMes ( InetAddr );
break;
}
}

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

bool CProtocol::EvaluateCLReqServerFeaturesMes ( const CHostAddress& InetAddr )
{
// invoke message action
emit CLReqServerFeatures ( InetAddr );

return false; // no error
}

void CProtocol::CreateCLServerFeaturesMes ( const CHostAddress& InetAddr, const uint32_t iFeatures )
{
int iPos = 0; // init position pointer
CVector<uint8_t> vecData ( 4 );

PutValOnStream ( vecData, iPos, iFeatures, 4 );

CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_FEATURES, vecData, InetAddr );
}

/******************************************************************************\
* Message generation and parsing *
\******************************************************************************/
Expand Down
5 changes: 5 additions & 0 deletions src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,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_FEATURES 1019 // server features message
#define PROTMESSID_CLM_REQ_SERVER_FEATURES 1020 // request server features

// special IDs
#define PROTMESSID_SPECIAL_SPLIT_MESSAGE 2001 // a container for split messages
Expand Down Expand Up @@ -177,6 +179,7 @@ class CProtocol : public QObject
void CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr );
void CreateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector<uint16_t>& vecLevelList, const int iNumClients );
void CreateCLRegisterServerResp ( const CHostAddress& InetAddr, const ESvrRegResult eResult );
void CreateCLServerFeaturesMes ( const CHostAddress& InetAddr, const uint32_t iResult );

static bool ParseMessageFrame ( const CVector<uint8_t>& vecbyData,
const int iNumBytesIn,
Expand Down Expand Up @@ -304,6 +307,7 @@ class CProtocol : public QObject
bool EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr );
bool EvaluateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData );
bool EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData );
bool EvaluateCLReqServerFeaturesMes ( const CHostAddress& InetAddr );

int iOldRecID;
int iOldRecCnt;
Expand Down Expand Up @@ -371,4 +375,5 @@ public slots:
void CLReqConnClientsList ( CHostAddress InetAddr );
void CLChannelLevelListReceived ( CHostAddress InetAddr, CVector<uint16_t> vecLevelList );
void CLRegisterServerResp ( CHostAddress InetAddr, ESvrRegResult eStatus );
void CLReqServerFeatures ( CHostAddress InetAddr );
};
57 changes: 57 additions & 0 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
\******************************************************************************/

#include "server.h"
#include "util.h"

// CServer implementation ******************************************************
CServer::CServer ( const int iNewMaxNumChan,
Expand Down Expand Up @@ -291,6 +292,8 @@ CServer::CServer ( const int iNewMaxNumChan,

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

QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqServerFeatures, this, &CServer::OnCLReqServerFeatures );

QObject::connect ( &ServerListManager, &CServerListManager::SvrRegStatusChanged, this, &CServer::SvrRegStatusChanged );

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

void CServer::OnCLReqServerFeatures ( CHostAddress RecHostAddr )
{
// This is a bitmask of features enabled at the server.
// EFeatureSet from util.h is used to shift each bool into position
uint32_t iFeatures = 0;

// Use 64 samples frame size mode? (argument -F)
iFeatures |= ( !bUseDoubleSystemFrameSize << FS_FAST_UPDATE );

// Multithreading enabled? (argument -T)
iFeatures |= ( bUseMultithreading << FS_MULTITHREADING );

// Recording directory set? (argument -R)
// If a recording directory is set a server could potentially record all client audio
iFeatures |= ( GetRecorderInitialised() << FS_RECORDER_ENABLED );

// Will an idle server start recording when a client joins or is it already recording an active session?
// (argument --norecord disables recording by default)
iFeatures |= ( ( JamController.GetRecorderState() == RS_RECORDING ) << FS_IS_RECORDING );

// Delay pan enabled? (argument -P)
iFeatures |= ( bDelayPan << FS_DELAY_PAN );

// IPv6 available? (argument --noipv6 disables this feature)
iFeatures |= ( bIPv6Available << FS_IPV6_AVAILABLE );

// "Max" audio quality setting enabled? (argument --noraw disables this feature)
iFeatures |= ( !bDisableRaw << FS_RAW_AUDIO );

// Disconnect all clients on quit? (argument -d)
iFeatures |= ( bDisconnectAllClientsOnQuit << FS_DISCONONQUIT );

// Has welcome message? (argument -w)
iFeatures |= ( !strWelcomeMessage.isEmpty() << FS_HAS_WELCOME_MESSAGE );

// Logging enabled? (argument -l)
iFeatures |= ( Logging.IsLogging() << FS_IS_LOGGING );

// Licence agreement required? (argument -L)
iFeatures |= ( ( eLicenceType != LT_NO_LICENCE ) << FS_HAS_LICENCE );

// TODO:
// Running a GUI? (argument -n disables the GUI)
// iFeatures |= ( << FS_HAS_GUI );
//
// // RPC interface enabled? (argument --jsonrpcport)
// iFeatures |= ( << FS_RPC_ENABLED );

// qDebug() << QString::number(iFeatures, 2).rightJustified(32, '0');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to leave this in for the moment for documentation purposes. This is supposed to be used for possible future enhancements and I think the comments reflect that well enough.


// Create and send the message
ConnLessProtocol.CreateCLServerFeaturesMes ( RecHostAddr, iFeatures );
}

void CServer::OnServerFull ( CHostAddress RecHostAddr )
{
// note: no mutex required here
Expand Down
2 changes: 2 additions & 0 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ public slots:

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

void OnCLReqServerFeatures ( CHostAddress InetAddr );

void OnCLDisconnection ( CHostAddress InetAddr );

void OnAboutToQuit();
Expand Down
1 change: 1 addition & 0 deletions src/serverlogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class CServerLogging
void AddServerStopped();

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

protected:
void operator<< ( const QString& sNewStr );
Expand Down
19 changes: 19 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,25 @@ enum EDirectoryType
AT_CUSTOM = 7 // Must be the last entry!
};

// Server feature set ----------------------------------------------------------
enum EFeatureSet
{
// used for protocol -> enum values must be fixed
FS_FAST_UPDATE = 0,
FS_MULTITHREADING = 1,
FS_RECORDER_ENABLED = 2,
FS_IS_RECORDING = 3,
FS_DELAY_PAN = 4,
FS_IPV6_AVAILABLE = 5,
FS_RAW_AUDIO = 6,
FS_DISCONONQUIT = 7,
FS_HAS_WELCOME_MESSAGE = 8,
FS_IS_LOGGING = 9,
FS_HAS_LICENCE = 10,
FS_HAS_GUI = 11,
FS_RPC_ENABLED = 12
};
Comment thread
dingodoppelt marked this conversation as resolved.

inline QString DirectoryTypeToString ( EDirectoryType eAddrType )
{
switch ( eAddrType )
Expand Down
Loading