From 1cf64931ff4c1b763dc9a144f94366df66feb37d Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Tue, 11 Jan 2022 10:33:15 +0200 Subject: [PATCH] Added some message types, removed protocolbuffer dependency and added msgpack dependency --- dub.json | 5 ++- source/libdnet/types.d | 77 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 source/libdnet/types.d diff --git a/dub.json b/dub.json index 109ab0a..fa4700b 100644 --- a/dub.json +++ b/dub.json @@ -3,8 +3,11 @@ "Tristan B. Kildaire" ], "copyright": "Copyright © 2021, Tristan B. Kildaire", + "dependencies": { + "msgpack-d": "~>1.0.3" + }, "description": "Client-side DNET API", "license": "LGPLv2", "name": "libdnet", "targetType": "library" -} +} \ No newline at end of file diff --git a/source/libdnet/types.d b/source/libdnet/types.d new file mode 100644 index 0000000..79effb4 --- /dev/null +++ b/source/libdnet/types.d @@ -0,0 +1,77 @@ +/** +* Type declarations +*/ +module libdnet.types; + +import msgpack; + +/* TODO: Add structs here */ + + +public enum HeaderType +{ + CLIENT, + SERVER +} + +/** +* Header format +* +* [ messageType | payload ] +*/ +struct Header +{ + /** + * Type of message + * + * How the `payload` should be + * interpreted + */ + HeaderType type; + + /** + * Data of the message + */ + ubyte[] payload; +} + + +/** +* Server message +* +* TODO: Describe message +*/ +struct ServerMessage +{ + /* TODO: Populate */ +} + + +/** +* ClientType +* +* The type of ClientMessage +*/ +public enum ClientType +{ + AUTH +} + +/** +* Client message +* +* TODO: Describe message +*/ +struct ClientMessage +{ + /* TODO: Populate */ + ClientType type; + + ubyte[] payload; +} + +struct AuthenticateMessage +{ + string username; + string password; +}