From c7080afd0f236c7e3af146cae1cb6bb649003f5d Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Sun, 14 Jun 2020 18:17:12 +0100 Subject: [PATCH] Define protocol message for server jam recorder state publishing --- src/protocol.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/protocol.h | 4 ++++ src/util.h | 8 ++++++++ 3 files changed, 58 insertions(+) mode change 100644 => 100755 src/protocol.h diff --git a/src/protocol.cpp b/src/protocol.cpp index 32b4de4f..c7810902 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -216,6 +216,17 @@ MESSAGES (with connection) note: does not have any data -> n = 0 +- PROTMESSID_RECORDER_STATE: notifies of changes in the server jam recorder state + + +--------------+ + | 1 byte state | + +--------------+ + + state is a value from the enum ERecorderState: + - 0 undefined (not used by protocol messages) + - tbc + + CONNECTION LESS MESSAGES ------------------------ @@ -659,6 +670,10 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false; case PROTMESSID_VERSION_AND_OS: bRet = EvaluateVersionAndOSMes ( vecbyMesBodyData ); break; + + case PROTMESSID_RECORDER_STATE: + bRet = EvaluateRecorderStateMes ( vecbyMesBodyData ); + break; } // immediately send acknowledge message @@ -1544,6 +1559,37 @@ bool CProtocol::EvaluateVersionAndOSMes ( const CVector& vecData ) return false; // no error } +void CProtocol::CreateRecorderStateMes ( const ERecorderState eRecorderState ) +{ + CVector vecData ( 1 ); // 1 byte of data + int iPos = 0; // init position pointer + + // build data vector + // recorder state + PutValOnStream ( vecData, iPos, static_cast ( eRecorderState ), 1 ); + + CreateAndSendMessage ( PROTMESSID_RECORDER_STATE, vecData ); +} + +bool CProtocol::EvaluateRecorderStateMes(const CVector& vecData) +{ + int iPos = 0; // init position pointer + + // check size + if ( vecData.Size() != 1 ) + { + return true; // return error code + } + + // server jam recorder state + const ERecorderState eRecorderState = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + + // invoke message action + emit RecorderStateReceived ( eRecorderState ); + + return false; // no error +} + // Connection less messages ---------------------------------------------------- void CProtocol::CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ) diff --git a/src/protocol.h b/src/protocol.h old mode 100644 new mode 100755 index 0c154e11..2c4a0760 --- a/src/protocol.h +++ b/src/protocol.h @@ -59,6 +59,7 @@ #define PROTMESSID_CHANNEL_PAN 30 // set channel pan for mix #define PROTMESSID_MUTE_STATE_CHANGED 31 // mute state of your signal at another client has changed #define PROTMESSID_CLIENT_ID 32 // current user ID and server status +#define PROTMESSID_RECORDER_STATE 33 // contains the state of the jam recorder (ERecorderState) // message IDs of connection less messages (CLM) // DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID @@ -114,6 +115,7 @@ public: void CreateOpusSupportedMes(); void CreateReqChannelLevelListMes ( const bool bRCL ); void CreateVersionAndOSMes(); + void CreateRecorderStateMes ( const ERecorderState eRecorderState ); void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ); void CreateCLPingWithNumClientsMes ( const CHostAddress& InetAddr, @@ -239,6 +241,7 @@ protected: bool EvaluateLicenceRequiredMes ( const CVector& vecData ); bool EvaluateReqChannelLevelListMes ( const CVector& vecData ); bool EvaluateVersionAndOSMes ( const CVector& vecData ); + bool EvaluateRecorderStateMes ( const CVector& vecData ); bool EvaluateCLPingMes ( const CHostAddress& InetAddr, const CVector& vecData ); @@ -302,6 +305,7 @@ signals: void LicenceRequired ( ELicenceType eLicenceType ); void ReqChannelLevelList ( bool bOptIn ); void VersionAndOSReceived ( COSUtil::EOpSystemType eOSType, QString strVersion ); + void RecorderStateReceived ( ERecorderState eRecorderState ); void CLPingReceived ( CHostAddress InetAddr, int iMs ); diff --git a/src/util.h b/src/util.h index 6e24312b..f317aa8e 100755 --- a/src/util.h +++ b/src/util.h @@ -563,6 +563,14 @@ enum ELicenceType }; +// Server jam recorder state enum ---------------------------------------------- +enum ERecorderState +{ + RS_UNDEFINED = 0 + // ... to be defined ... +}; + + // Channel sort type ----------------------------------------------------------- enum EChSortType {