2017-08-27 21:10:20 +00:00
|
|
|
|
|
|
|
// ForgeHandshake.h
|
|
|
|
|
|
|
|
// Implements Forge protocol handshaking
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2018-08-29 00:51:25 +00:00
|
|
|
#include "../UUID.h"
|
2017-08-27 21:10:20 +00:00
|
|
|
#include "json/json.h"
|
|
|
|
|
2021-10-02 20:27:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-08-27 21:10:20 +00:00
|
|
|
// fwd:
|
|
|
|
class cClientHandle;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cForgeHandshake
|
|
|
|
{
|
|
|
|
public:
|
2021-10-02 20:27:32 +00:00
|
|
|
|
2017-08-27 21:10:20 +00:00
|
|
|
/** True if the client advertised itself as a Forge client. */
|
2021-10-02 20:27:32 +00:00
|
|
|
bool IsForgeClient;
|
2017-08-27 21:10:20 +00:00
|
|
|
|
2021-10-02 20:27:32 +00:00
|
|
|
cForgeHandshake();
|
2017-08-27 21:10:20 +00:00
|
|
|
|
|
|
|
/** Add the registered Forge mods to the server ping list packet. */
|
2021-10-02 20:27:32 +00:00
|
|
|
void AugmentServerListPing(cClientHandle & a_Client, Json::Value & ResponseValue);
|
2017-08-27 21:10:20 +00:00
|
|
|
|
|
|
|
/** Begin the Forge Modloader Handshake (FML|HS) sequence. */
|
2021-10-02 20:27:32 +00:00
|
|
|
void BeginForgeHandshake(cClientHandle & a_Client);
|
2017-08-27 21:10:20 +00:00
|
|
|
|
|
|
|
/** Send the ServerHello packet in the Forge handshake. */
|
2021-10-02 20:27:32 +00:00
|
|
|
void SendServerHello(cClientHandle & a_Client);
|
2017-08-27 21:10:20 +00:00
|
|
|
|
|
|
|
/** Process received data from the client advancing the Forge handshake. */
|
2021-10-02 20:27:32 +00:00
|
|
|
void DataReceived(cClientHandle & a_Client, ContiguousByteBufferView a_Data);
|
2017-08-27 21:10:20 +00:00
|
|
|
|
|
|
|
private:
|
2021-10-02 20:27:32 +00:00
|
|
|
|
2017-08-27 21:10:20 +00:00
|
|
|
/** True if the Forge handshake is in an errored state. */
|
|
|
|
bool m_Errored;
|
|
|
|
|
2021-10-02 20:27:32 +00:00
|
|
|
void HandleClientHello(cClientHandle & a_Client, ContiguousByteBufferView a_Data);
|
|
|
|
void HandleModList(cClientHandle & a_Client, ContiguousByteBufferView a_Data);
|
|
|
|
void HandleHandshakeAck(cClientHandle & a_Client, ContiguousByteBufferView a_Data);
|
2017-08-27 21:10:20 +00:00
|
|
|
|
|
|
|
/** Set errored state to prevent further handshake message processing. */
|
|
|
|
void SetError(const AString & message);
|
|
|
|
|
|
|
|
/** Parse the client ModList packet of installed Forge mods and versions. */
|
2021-01-11 16:39:43 +00:00
|
|
|
AStringMap ParseModList(ContiguousByteBufferView a_Data);
|
2017-08-27 21:10:20 +00:00
|
|
|
};
|