add new register message which contains server version
This commit is contained in:
parent
e0750d8b1a
commit
6a7f0a6dc3
7 changed files with 210 additions and 4 deletions
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TODO add new register message which contains version and, e.g., max number of clients
|
TODO bug fix: if group is set to disabled, reset "previous level"
|
||||||
|
|
||||||
TODO improve settings management -> move settings class in client/server classes, move actual settings variables
|
TODO improve settings management -> move settings class in client/server classes, move actual settings variables
|
||||||
TODO store recorder settings (#313)
|
TODO store recorder settings (#313)
|
||||||
|
@ -38,7 +38,6 @@ TODO Inconsistency between Input meter and Audio mixer meter #423
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
3.5.8 (2020-06-30)
|
3.5.8 (2020-06-30)
|
||||||
|
|
||||||
- bug fix: incorrect selection of UI language (#408)
|
- bug fix: incorrect selection of UI language (#408)
|
||||||
|
|
172
src/protocol.cpp
172
src/protocol.cpp
|
@ -289,6 +289,14 @@ CONNECTION LESS MESSAGES
|
||||||
necessary, that value will contain the server internal address.
|
necessary, that value will contain the server internal address.
|
||||||
|
|
||||||
|
|
||||||
|
- PROTMESSID_CLM_REGISTER_SERVER_EX: Register a server, providing extended server
|
||||||
|
information
|
||||||
|
|
||||||
|
+--------------------------------+-------------------------------+
|
||||||
|
| PROTMESSID_CLM_REGISTER_SERVER | PROTMESSID_CLM_VERSION_AND_OS |
|
||||||
|
+--------------------------------+-------------------------------+
|
||||||
|
|
||||||
|
|
||||||
- PROTMESSID_CLM_UNREGISTER_SERVER: Unregister a server
|
- PROTMESSID_CLM_UNREGISTER_SERVER: Unregister a server
|
||||||
|
|
||||||
note: does not have any data -> n = 0
|
note: does not have any data -> n = 0
|
||||||
|
@ -738,6 +746,10 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false;
|
||||||
bRet = EvaluateCLRegisterServerMes ( InetAddr, vecbyMesBodyData );
|
bRet = EvaluateCLRegisterServerMes ( InetAddr, vecbyMesBodyData );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROTMESSID_CLM_REGISTER_SERVER_EX:
|
||||||
|
bRet = EvaluateCLRegisterServerExMes ( InetAddr, vecbyMesBodyData );
|
||||||
|
break;
|
||||||
|
|
||||||
case PROTMESSID_CLM_UNREGISTER_SERVER:
|
case PROTMESSID_CLM_UNREGISTER_SERVER:
|
||||||
bRet = EvaluateCLUnregisterServerMes ( InetAddr );
|
bRet = EvaluateCLUnregisterServerMes ( InetAddr );
|
||||||
break;
|
break;
|
||||||
|
@ -1466,8 +1478,8 @@ void CProtocol::CreateReqChannelLevelListMes ( const bool bRCL )
|
||||||
{
|
{
|
||||||
CVector<uint8_t> vecData ( 1 ); // 1 byte of data
|
CVector<uint8_t> vecData ( 1 ); // 1 byte of data
|
||||||
int iPos = 0; // init position pointer
|
int iPos = 0; // init position pointer
|
||||||
PutValOnStream ( vecData, iPos,
|
|
||||||
static_cast<uint32_t> ( bRCL ), 1 );
|
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( bRCL ), 1 );
|
||||||
|
|
||||||
CreateAndSendMessage ( PROTMESSID_REQ_CHANNEL_LEVEL_LIST, vecData );
|
CreateAndSendMessage ( PROTMESSID_REQ_CHANNEL_LEVEL_LIST, vecData );
|
||||||
}
|
}
|
||||||
|
@ -1820,6 +1832,162 @@ bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
|
||||||
return false; // no error
|
return false; // no error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CProtocol::CreateCLRegisterServerExMes ( const CHostAddress& InetAddr,
|
||||||
|
const CHostAddress& LInetAddr,
|
||||||
|
const CServerCoreInfo& ServerInfo )
|
||||||
|
{
|
||||||
|
int iPos = 0; // init position pointer
|
||||||
|
|
||||||
|
// convert server info strings to utf-8
|
||||||
|
const QByteArray strUTF8LInetAddr = LInetAddr.InetAddr.toString().toUtf8();
|
||||||
|
const QByteArray strUTF8Name = ServerInfo.strName.toUtf8();
|
||||||
|
const QByteArray strUTF8City = ServerInfo.strCity.toUtf8();
|
||||||
|
const QByteArray strUTF8Version = QString ( VERSION ).toUtf8();
|
||||||
|
|
||||||
|
// size of current message body
|
||||||
|
const int iEntrLen =
|
||||||
|
2 /* server internal port number */ +
|
||||||
|
2 /* country */ +
|
||||||
|
1 /* maximum number of connected clients */ +
|
||||||
|
1 /* is permanent flag */ +
|
||||||
|
2 /* name utf-8 string size */ + strUTF8Name.size() +
|
||||||
|
2 /* server internal address utf-8 string size */ + strUTF8LInetAddr.size() +
|
||||||
|
2 /* city utf-8 string size */ + strUTF8City.size() +
|
||||||
|
1 /* operating system */ +
|
||||||
|
2 /* version utf-8 string size */ + strUTF8Version.size();
|
||||||
|
|
||||||
|
// build data vector
|
||||||
|
CVector<uint8_t> vecData ( iEntrLen );
|
||||||
|
|
||||||
|
// port number (2 bytes)
|
||||||
|
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( LInetAddr.iPort ), 2 );
|
||||||
|
|
||||||
|
// country (2 bytes)
|
||||||
|
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( ServerInfo.eCountry ), 2 );
|
||||||
|
|
||||||
|
// maximum number of connected clients (1 byte)
|
||||||
|
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( ServerInfo.iMaxNumClients ), 1 );
|
||||||
|
|
||||||
|
// "is permanent" flag (1 byte)
|
||||||
|
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( ServerInfo.bPermanentOnline ), 1 );
|
||||||
|
|
||||||
|
// name
|
||||||
|
PutStringUTF8OnStream ( vecData, iPos, strUTF8Name );
|
||||||
|
|
||||||
|
// server internal address (formerly unused topic)
|
||||||
|
PutStringUTF8OnStream ( vecData, iPos, strUTF8LInetAddr );
|
||||||
|
|
||||||
|
// city
|
||||||
|
PutStringUTF8OnStream ( vecData, iPos, strUTF8City );
|
||||||
|
|
||||||
|
// operating system (1 byte)
|
||||||
|
PutValOnStream ( vecData, iPos,
|
||||||
|
static_cast<uint32_t> ( COSUtil::GetOperatingSystem() ), 1 );
|
||||||
|
|
||||||
|
// version
|
||||||
|
PutStringUTF8OnStream ( vecData, iPos, strUTF8Version );
|
||||||
|
|
||||||
|
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REGISTER_SERVER,
|
||||||
|
vecData,
|
||||||
|
InetAddr );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CProtocol::EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr,
|
||||||
|
const CVector<uint8_t>& vecData )
|
||||||
|
{
|
||||||
|
int iPos = 0; // init position pointer
|
||||||
|
const int iDataLen = vecData.Size();
|
||||||
|
QString sLocHost; // temp string for server internal address
|
||||||
|
CHostAddress LInetAddr;
|
||||||
|
CServerCoreInfo RecServerInfo;
|
||||||
|
|
||||||
|
// check size (the first 6 bytes)
|
||||||
|
if ( iDataLen < 6 )
|
||||||
|
{
|
||||||
|
return true; // return error code
|
||||||
|
}
|
||||||
|
|
||||||
|
// port number (2 bytes)
|
||||||
|
LInetAddr.iPort = static_cast<quint16> ( GetValFromStream ( vecData, iPos, 2 ) );
|
||||||
|
|
||||||
|
// country (2 bytes)
|
||||||
|
RecServerInfo.eCountry = static_cast<QLocale::Country> ( GetValFromStream ( vecData, iPos, 2 ) );
|
||||||
|
|
||||||
|
// maximum number of connected clients (1 byte)
|
||||||
|
RecServerInfo.iMaxNumClients = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
|
||||||
|
|
||||||
|
// "is permanent" flag (1 byte)
|
||||||
|
RecServerInfo.bPermanentOnline = static_cast<bool> ( GetValFromStream ( vecData, iPos, 1 ) );
|
||||||
|
|
||||||
|
// server name
|
||||||
|
if ( GetStringFromStream ( vecData,
|
||||||
|
iPos,
|
||||||
|
MAX_LEN_SERVER_NAME,
|
||||||
|
RecServerInfo.strName ) )
|
||||||
|
{
|
||||||
|
return true; // return error code
|
||||||
|
}
|
||||||
|
|
||||||
|
// server internal address
|
||||||
|
if ( GetStringFromStream ( vecData,
|
||||||
|
iPos,
|
||||||
|
MAX_LEN_IP_ADDRESS,
|
||||||
|
sLocHost ) )
|
||||||
|
{
|
||||||
|
return true; // return error code
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( sLocHost.isEmpty() )
|
||||||
|
{
|
||||||
|
// old server, empty "topic", register as local host
|
||||||
|
LInetAddr.InetAddr.setAddress ( QHostAddress::LocalHost );
|
||||||
|
}
|
||||||
|
else if ( !LInetAddr.InetAddr.setAddress ( sLocHost ) )
|
||||||
|
{
|
||||||
|
return true; // return error code
|
||||||
|
}
|
||||||
|
|
||||||
|
// server city
|
||||||
|
if ( GetStringFromStream ( vecData,
|
||||||
|
iPos,
|
||||||
|
MAX_LEN_SERVER_CITY,
|
||||||
|
RecServerInfo.strCity ) )
|
||||||
|
{
|
||||||
|
return true; // return error code
|
||||||
|
}
|
||||||
|
|
||||||
|
// check size (the next 1 byte)
|
||||||
|
if ( iDataLen < iPos + 1 )
|
||||||
|
{
|
||||||
|
return true; // return error code
|
||||||
|
}
|
||||||
|
|
||||||
|
// operating system (1 byte)
|
||||||
|
const COSUtil::EOpSystemType eOSType =
|
||||||
|
static_cast<COSUtil::EOpSystemType> ( GetValFromStream ( vecData, iPos, 1 ) );
|
||||||
|
|
||||||
|
// version text
|
||||||
|
QString strVersion;
|
||||||
|
if ( GetStringFromStream ( vecData,
|
||||||
|
iPos,
|
||||||
|
MAX_LEN_VERSION_TEXT,
|
||||||
|
strVersion ) )
|
||||||
|
{
|
||||||
|
return true; // return error code
|
||||||
|
}
|
||||||
|
|
||||||
|
// check size: all data is read, the position must now be at the end
|
||||||
|
if ( iPos != iDataLen )
|
||||||
|
{
|
||||||
|
return true; // return error code
|
||||||
|
}
|
||||||
|
|
||||||
|
// invoke message action
|
||||||
|
emit CLRegisterServerExReceived ( InetAddr, LInetAddr, RecServerInfo, eOSType, strVersion );
|
||||||
|
|
||||||
|
return false; // no error
|
||||||
|
}
|
||||||
|
|
||||||
void CProtocol::CreateCLUnregisterServerMes ( const CHostAddress& InetAddr )
|
void CProtocol::CreateCLUnregisterServerMes ( const CHostAddress& InetAddr )
|
||||||
{
|
{
|
||||||
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_UNREGISTER_SERVER,
|
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_UNREGISTER_SERVER,
|
||||||
|
|
|
@ -79,6 +79,7 @@
|
||||||
#define PROTMESSID_CLM_REQ_CONN_CLIENTS_LIST 1014 // request the connected clients list
|
#define PROTMESSID_CLM_REQ_CONN_CLIENTS_LIST 1014 // request the connected clients list
|
||||||
#define PROTMESSID_CLM_CHANNEL_LEVEL_LIST 1015 // channel level list
|
#define PROTMESSID_CLM_CHANNEL_LEVEL_LIST 1015 // channel level list
|
||||||
#define PROTMESSID_CLM_REGISTER_SERVER_RESP 1016 // status of server registration request
|
#define PROTMESSID_CLM_REGISTER_SERVER_RESP 1016 // status of server registration request
|
||||||
|
#define PROTMESSID_CLM_REGISTER_SERVER_EX 1017 // register server with extended information
|
||||||
|
|
||||||
// lengths of message as defined in protocol.cpp file
|
// lengths of message as defined in protocol.cpp file
|
||||||
#define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2)
|
#define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2)
|
||||||
|
@ -125,6 +126,9 @@ public:
|
||||||
void CreateCLRegisterServerMes ( const CHostAddress& InetAddr,
|
void CreateCLRegisterServerMes ( const CHostAddress& InetAddr,
|
||||||
const CHostAddress& LInetAddr,
|
const CHostAddress& LInetAddr,
|
||||||
const CServerCoreInfo& ServerInfo );
|
const CServerCoreInfo& ServerInfo );
|
||||||
|
void CreateCLRegisterServerExMes ( const CHostAddress& InetAddr,
|
||||||
|
const CHostAddress& LInetAddr,
|
||||||
|
const CServerCoreInfo& ServerInfo );
|
||||||
void CreateCLUnregisterServerMes ( const CHostAddress& InetAddr );
|
void CreateCLUnregisterServerMes ( const CHostAddress& InetAddr );
|
||||||
void CreateCLServerListMes ( const CHostAddress& InetAddr,
|
void CreateCLServerListMes ( const CHostAddress& InetAddr,
|
||||||
const CVector<CServerInfo> vecServerInfo );
|
const CVector<CServerInfo> vecServerInfo );
|
||||||
|
@ -250,6 +254,8 @@ protected:
|
||||||
bool EvaluateCLServerFullMes();
|
bool EvaluateCLServerFullMes();
|
||||||
bool EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
|
bool EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
|
||||||
const CVector<uint8_t>& vecData );
|
const CVector<uint8_t>& vecData );
|
||||||
|
bool EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr,
|
||||||
|
const CVector<uint8_t>& vecData );
|
||||||
bool EvaluateCLUnregisterServerMes ( const CHostAddress& InetAddr );
|
bool EvaluateCLUnregisterServerMes ( const CHostAddress& InetAddr );
|
||||||
bool EvaluateCLServerListMes ( const CHostAddress& InetAddr,
|
bool EvaluateCLServerListMes ( const CHostAddress& InetAddr,
|
||||||
const CVector<uint8_t>& vecData );
|
const CVector<uint8_t>& vecData );
|
||||||
|
@ -315,6 +321,11 @@ signals:
|
||||||
void CLRegisterServerReceived ( CHostAddress InetAddr,
|
void CLRegisterServerReceived ( CHostAddress InetAddr,
|
||||||
CHostAddress LInetAddr,
|
CHostAddress LInetAddr,
|
||||||
CServerCoreInfo ServerInfo );
|
CServerCoreInfo ServerInfo );
|
||||||
|
void CLRegisterServerExReceived ( CHostAddress InetAddr,
|
||||||
|
CHostAddress LInetAddr,
|
||||||
|
CServerCoreInfo ServerInfo,
|
||||||
|
COSUtil::EOpSystemType eOSType,
|
||||||
|
QString strVersion );
|
||||||
void CLUnregisterServerReceived ( CHostAddress InetAddr );
|
void CLUnregisterServerReceived ( CHostAddress InetAddr );
|
||||||
void CLServerListReceived ( CHostAddress InetAddr,
|
void CLServerListReceived ( CHostAddress InetAddr,
|
||||||
CVector<CServerInfo> vecServerInfo );
|
CVector<CServerInfo> vecServerInfo );
|
||||||
|
|
|
@ -449,6 +449,9 @@ CServer::CServer ( const int iNewMaxNumChan,
|
||||||
QObject::connect ( &ConnLessProtocol, &CProtocol::CLRegisterServerReceived,
|
QObject::connect ( &ConnLessProtocol, &CProtocol::CLRegisterServerReceived,
|
||||||
this, &CServer::OnCLRegisterServerReceived );
|
this, &CServer::OnCLRegisterServerReceived );
|
||||||
|
|
||||||
|
QObject::connect ( &ConnLessProtocol, &CProtocol::CLRegisterServerExReceived,
|
||||||
|
this, &CServer::OnCLRegisterServerExReceived );
|
||||||
|
|
||||||
QObject::connect ( &ConnLessProtocol, &CProtocol::CLUnregisterServerReceived,
|
QObject::connect ( &ConnLessProtocol, &CProtocol::CLUnregisterServerReceived,
|
||||||
this, &CServer::OnCLUnregisterServerReceived );
|
this, &CServer::OnCLUnregisterServerReceived );
|
||||||
|
|
||||||
|
|
|
@ -462,6 +462,15 @@ public slots:
|
||||||
ServerListManager.CentralServerRegisterServer ( InetAddr, LInetAddr, ServerInfo );
|
ServerListManager.CentralServerRegisterServer ( InetAddr, LInetAddr, ServerInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnCLRegisterServerExReceived ( CHostAddress InetAddr,
|
||||||
|
CHostAddress LInetAddr,
|
||||||
|
CServerCoreInfo ServerInfo,
|
||||||
|
COSUtil::EOpSystemType eOSType,
|
||||||
|
QString strVersion )
|
||||||
|
{
|
||||||
|
ServerListManager.CentralServerRegisterServerEx ( InetAddr, LInetAddr, ServerInfo, eOSType, strVersion );
|
||||||
|
}
|
||||||
|
|
||||||
void OnCLRegisterServerResp ( CHostAddress /* unused */,
|
void OnCLRegisterServerResp ( CHostAddress /* unused */,
|
||||||
ESvrRegResult eResult )
|
ESvrRegResult eResult )
|
||||||
{
|
{
|
||||||
|
|
|
@ -340,6 +340,16 @@ void CServerListManager::OnTimerPollList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CServerListManager::CentralServerRegisterServerEx ( const CHostAddress& InetAddr,
|
||||||
|
const CHostAddress& LInetAddr,
|
||||||
|
const CServerCoreInfo& ServerInfo,
|
||||||
|
const COSUtil::EOpSystemType ,
|
||||||
|
const QString& )
|
||||||
|
{
|
||||||
|
// TODO right now we do not make use of the additional operating system and version number informations
|
||||||
|
CentralServerRegisterServer ( InetAddr, LInetAddr, ServerInfo );
|
||||||
|
}
|
||||||
|
|
||||||
void CServerListManager::CentralServerRegisterServer ( const CHostAddress& InetAddr,
|
void CServerListManager::CentralServerRegisterServer ( const CHostAddress& InetAddr,
|
||||||
const CHostAddress& LInetAddr,
|
const CHostAddress& LInetAddr,
|
||||||
const CServerCoreInfo& ServerInfo )
|
const CServerCoreInfo& ServerInfo )
|
||||||
|
|
|
@ -147,6 +147,12 @@ public:
|
||||||
const CHostAddress& LInetAddr,
|
const CHostAddress& LInetAddr,
|
||||||
const CServerCoreInfo& ServerInfo );
|
const CServerCoreInfo& ServerInfo );
|
||||||
|
|
||||||
|
void CentralServerRegisterServerEx ( const CHostAddress& InetAddr,
|
||||||
|
const CHostAddress& LInetAddr,
|
||||||
|
const CServerCoreInfo& ServerInfo,
|
||||||
|
const COSUtil::EOpSystemType ,
|
||||||
|
const QString& );
|
||||||
|
|
||||||
void CentralServerUnregisterServer ( const CHostAddress& InetAddr );
|
void CentralServerUnregisterServer ( const CHostAddress& InetAddr );
|
||||||
|
|
||||||
void CentralServerQueryServerList ( const CHostAddress& InetAddr );
|
void CentralServerQueryServerList ( const CHostAddress& InetAddr );
|
||||||
|
|
Loading…
Reference in a new issue