From 4ef186dba2cd347ba9a89fbce1567865079b2a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amedeo=20Moln=C3=A1r?= Date: Tue, 23 Jan 2024 11:35:22 +0100 Subject: [PATCH] add comments to messages --- src-lib/Library/Types/Communication.hs | 32 +++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src-lib/Library/Types/Communication.hs b/src-lib/Library/Types/Communication.hs index a158706..b576373 100644 --- a/src-lib/Library/Types/Communication.hs +++ b/src-lib/Library/Types/Communication.hs @@ -13,16 +13,20 @@ import Library.Types.Player import Library.Types.Map data ServerMessage - = ServerQuit - | AcceptClient + = ServerQuit -- ^ Message notifying a client that the server is about to shut down. + | Ping -- ^ A servers's heartbeat request + { pingID :: UUID -- ^ The random ID of the heartbeat request. NOT THE CLIENT'S 'UUID'! + } + | AcceptClient -- ^ Message notifying the client of being accepted and providing it's + -- newly registered 'UUID' { acClientUUID :: UUID } - | ProvideInitialWizard + | ProvideInitialWizard -- ^ Message containing a newly created player character { initWizard :: Wizard } - | TickUpdate - { tuMapSlice :: MapSlice - , tuWizard :: Wizard + | TickUpdate -- ^ The Server's state update to the clients + { tuMapSlice :: MapSlice -- ^ The player's field of vision + , tuWizard :: Wizard -- ^ the player's updated character } deriving (Eq, Show, Generic) @@ -31,17 +35,19 @@ instance FromJSON ServerMessage instance ToJSON ServerMessage data ClientMessagePayload - = ClientQuit - | ClientRequestWizard - | ClientReady + = ClientQuit -- ^ Message notifying the server of a client about to shut down + | ClientRequestWizard -- ^ Message for requesting a new player character + | ClientReady -- ^ Message requesting the server to position the client's character on the + -- map deriving (Eq, Show, Generic) data ClientMessage - = ClientMessage - { cmClientID :: UUID - , cmPayload :: ClientMessagePayload + = ClientMessage -- ^ A general client message to pass to the serve + { cmClientID :: UUID -- ^ The client's 'UUID' for identification + , cmPayload :: ClientMessagePayload -- ^ The actual message payload } - | IdRequest + | IdRequest -- ^ A special message to the server for requesting a new + -- 'UUID' ad startup deriving (Eq, Show, Generic) instance FromJSON ClientMessagePayload