add comments to messages

This commit is contained in:
Amedeo Molnár 2024-01-23 11:35:22 +01:00
parent 98214fdb38
commit 4ef186dba2

View file

@ -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