summaryrefslogtreecommitdiffstats
path: root/src/Protocol/ForgeHandshake.h
diff options
context:
space:
mode:
authorsatoshinm <snmatsutake@yahoo.co.jp>2017-08-27 23:10:20 +0200
committerMattes D <github@xoft.cz>2017-08-27 23:10:20 +0200
commit6bc503151746ea05842009983c7de932fa80cd03 (patch)
treea7ce87c25b2acb9c5f76cd1a25180b77ebf16f26 /src/Protocol/ForgeHandshake.h
parentImplement anvil chunk sparsing (diff)
downloadcuberite-6bc503151746ea05842009983c7de932fa80cd03.tar
cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar.gz
cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar.bz2
cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar.lz
cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar.xz
cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar.zst
cuberite-6bc503151746ea05842009983c7de932fa80cd03.zip
Diffstat (limited to 'src/Protocol/ForgeHandshake.h')
-rw-r--r--src/Protocol/ForgeHandshake.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/Protocol/ForgeHandshake.h b/src/Protocol/ForgeHandshake.h
new file mode 100644
index 000000000..f7be9e958
--- /dev/null
+++ b/src/Protocol/ForgeHandshake.h
@@ -0,0 +1,60 @@
+
+// ForgeHandshake.h
+
+// Implements Forge protocol handshaking
+
+#pragma once
+
+#include <stddef.h>
+#include "UUID.h"
+#include "json/json.h"
+
+// fwd:
+class cClientHandle;
+
+
+
+
+
+class cForgeHandshake
+{
+public:
+ /** True if the client advertised itself as a Forge client. */
+ bool m_IsForgeClient;
+
+ cForgeHandshake(cClientHandle * client);
+
+ /** Add the registered Forge mods to the server ping list packet. */
+ void AugmentServerListPing(Json::Value & ResponseValue);
+
+ /** Begin the Forge Modloader Handshake (FML|HS) sequence. */
+ void BeginForgeHandshake(const AString & a_Name, const cUUID & a_UUID, const Json::Value & a_Properties);
+
+ /** Send the ServerHello packet in the Forge handshake. */
+ void SendServerHello();
+
+ /** Process received data from the client advancing the Forge handshake. */
+ void DataReceived(cClientHandle * a_Client, const char * a_Data, size_t a_Size);
+
+private:
+ /** True if the Forge handshake is in an errored state. */
+ bool m_Errored;
+
+ /** The client handle undergoing this Forge handshake. */
+ cClientHandle * m_Client;
+
+ /** Values saved from BeginForgeHandshake() for continuing the normal handshake after Forge completes. */
+ AString m_Name;
+ cUUID m_UUID;
+ Json::Value m_Properties;
+
+ void HandleClientHello(cClientHandle * a_Client, const char * a_Data, size_t a_Size);
+ void HandleModList(cClientHandle * a_Client, const char * a_Data, size_t a_Size);
+ void HandleHandshakeAck(cClientHandle * a_Client, const char * a_Data, size_t a_Size);
+
+ /** 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. */
+ AStringMap ParseModList(const char * a_Data, size_t a_Size);
+};