implementation of all necessary connection less messages finished
This commit is contained in:
parent
ae660bb459
commit
daa8a0eecb
2 changed files with 76 additions and 9 deletions
|
@ -206,6 +206,12 @@ CONNECTION LESS MESSAGES
|
|||
note: does not have any data -> n = 0
|
||||
|
||||
|
||||
- PROTMESSID_CLM_SEND_EMPTY_MESSAGE: Send "empty message" message
|
||||
|
||||
+--------------------+--------------+
|
||||
| 4 bytes IP address | 2 bytes port |
|
||||
+--------------------+--------------+
|
||||
|
||||
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -570,7 +576,7 @@ bool CProtocol::ParseConnectionLessMessage ( const CVector<uint8_t>& vecbyData,
|
|||
break;
|
||||
|
||||
case PROTMESSID_CLM_SEND_EMPTY_MESSAGE:
|
||||
// TODO
|
||||
bRet = EvaluateCLSendEmptyMesMes ( InetAddr, vecData );
|
||||
break;
|
||||
|
||||
case PROTMESSID_CLM_REGISTER_SERVER:
|
||||
|
@ -892,7 +898,7 @@ void CProtocol::CreatePingMes ( const int iMs )
|
|||
// build data vector (4 bytes long)
|
||||
CVector<uint8_t> vecData ( 4 );
|
||||
|
||||
// byte-by-byte copying of the string data
|
||||
// transmit time (4 bytes)
|
||||
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iMs ), 4 );
|
||||
|
||||
CreateAndSendMessage ( PROTMESSID_PING_MS, vecData );
|
||||
|
@ -1100,7 +1106,7 @@ void CProtocol::CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs )
|
|||
// build data vector (4 bytes long)
|
||||
CVector<uint8_t> vecData ( 4 );
|
||||
|
||||
// byte-by-byte copying of the string data
|
||||
// transmit time (4 bytes)
|
||||
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iMs ), 4 );
|
||||
|
||||
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_PING_MS,
|
||||
|
@ -1431,6 +1437,60 @@ bool CProtocol::EvaluateCLReqServerListMes ( const CHostAddress& InetAddr )
|
|||
return false; // no error
|
||||
}
|
||||
|
||||
void CProtocol::CreateCLSendEmptyMesMes ( const CHostAddress& InetAddr,
|
||||
const CHostAddress& TargetInetAddr )
|
||||
{
|
||||
int iPos = 0; // init position pointer
|
||||
|
||||
// build data vector (6 bytes long)
|
||||
CVector<uint8_t> vecData ( 6 );
|
||||
|
||||
// IP address (4 bytes)
|
||||
PutValOnStream ( vecData, iPos, static_cast<uint32_t> (
|
||||
TargetInetAddr.InetAddr.toIPv4Address() ), 4 );
|
||||
|
||||
// port number (2 bytes)
|
||||
PutValOnStream ( vecData, iPos,
|
||||
static_cast<uint32_t> ( TargetInetAddr.iPort ), 2 );
|
||||
|
||||
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SEND_EMPTY_MESSAGE,
|
||||
vecData,
|
||||
InetAddr );
|
||||
}
|
||||
|
||||
bool CProtocol::EvaluateCLSendEmptyMesMes ( const CHostAddress& InetAddr,
|
||||
const CVector<uint8_t>& vecData )
|
||||
{
|
||||
int iPos = 0; // init position pointer
|
||||
|
||||
// check size
|
||||
if ( vecData.Size() != 6 )
|
||||
{
|
||||
return true; // return error code
|
||||
}
|
||||
|
||||
// IP address (4 bytes)
|
||||
const quint32 iIpAddr =
|
||||
static_cast<int> ( GetValFromStream ( vecData, iPos, 4 ) );
|
||||
|
||||
// port number (2 bytes)
|
||||
const quint16 iPort =
|
||||
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
|
||||
|
||||
// invoke message action
|
||||
emit CLSendEmptyMes ( InetAddr,
|
||||
CHostAddress ( QHostAddress ( iIpAddr ), iPort ) );
|
||||
|
||||
return false; // no error
|
||||
}
|
||||
|
||||
void CProtocol::CreateCLEmptyMes ( const CHostAddress& InetAddr )
|
||||
{
|
||||
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_EMPTY_MESSAGE,
|
||||
CVector<uint8_t> ( 0 ),
|
||||
InetAddr );
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
* Message generation and parsing *
|
||||
|
|
|
@ -57,12 +57,12 @@
|
|||
// DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID
|
||||
#define PROTMESSID_CLM_PING_MS 1001 // for measuring ping time
|
||||
#define PROTMESSID_CLM_SERVER_FULL 1002 // server full message
|
||||
#define PROTMESSID_CLM_SERVER_LIST 1003 // server list
|
||||
#define PROTMESSID_CLM_REQ_SERVER_LIST 1004 // request server list
|
||||
#define PROTMESSID_CLM_SEND_EMPTY_MESSAGE 1005 // an empty message shall be send
|
||||
#define PROTMESSID_CLM_EMPTY_MESSAGE 1006 // empty message
|
||||
#define PROTMESSID_CLM_REGISTER_SERVER 1007 // register server
|
||||
#define PROTMESSID_CLM_UNREGISTER_SERVER 1008 // unregister server -> TODO
|
||||
#define PROTMESSID_CLM_REGISTER_SERVER 1003 // register server
|
||||
#define PROTMESSID_CLM_UNREGISTER_SERVER 1004 // unregister server -> TODO
|
||||
#define PROTMESSID_CLM_SERVER_LIST 1005 // server list
|
||||
#define PROTMESSID_CLM_REQ_SERVER_LIST 1006 // request server list
|
||||
#define PROTMESSID_CLM_SEND_EMPTY_MESSAGE 1007 // an empty message shall be send
|
||||
#define PROTMESSID_CLM_EMPTY_MESSAGE 1008 // empty message
|
||||
|
||||
|
||||
// lengths of message as defined in protocol.cpp file
|
||||
|
@ -102,6 +102,9 @@ public:
|
|||
void CreateCLServerListMes ( const CHostAddress& InetAddr,
|
||||
const CVector<CServerInfo> vecServerInfo );
|
||||
void CreateCLReqServerListMes ( const CHostAddress& InetAddr );
|
||||
void CreateCLSendEmptyMesMes ( const CHostAddress& InetAddr,
|
||||
const CHostAddress& TargetInetAddr );
|
||||
void CreateCLEmptyMes ( const CHostAddress& InetAddr );
|
||||
|
||||
void CreateAndImmSendDisconnectionMes();
|
||||
void CreateAndImmSendAcknMess ( const int& iID,
|
||||
|
@ -207,6 +210,8 @@ protected:
|
|||
bool EvaluateCLServerListMes ( const CHostAddress& InetAddr,
|
||||
const CVector<uint8_t>& vecData );
|
||||
bool EvaluateCLReqServerListMes ( const CHostAddress& InetAddr );
|
||||
bool EvaluateCLSendEmptyMesMes ( const CHostAddress& InetAddr,
|
||||
const CVector<uint8_t>& vecData );
|
||||
|
||||
int iOldRecID;
|
||||
int iOldRecCnt;
|
||||
|
@ -249,6 +254,8 @@ signals:
|
|||
void CLServerListReceived ( CHostAddress InetAddr,
|
||||
CVector<CServerInfo> vecServerInfo );
|
||||
void CLReqServerList ( CHostAddress InetAddr );
|
||||
void CLSendEmptyMes ( CHostAddress InetAddr,
|
||||
CHostAddress TargetInetAddr );
|
||||
};
|
||||
|
||||
#endif /* !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) */
|
||||
|
|
Loading…
Reference in a new issue