loshadka-0.2: Network/Loshadka/Protocol.hs
{-# LANGUAGE DeriveGeneric #-}
module Network.Loshadka.Protocol where
import Data.ByteString.Lazy.Char8 (ByteString)
import Data.Aeson hiding (encode)
import GHC.Generics (Generic)
-- Attention: Minecraft clients check for compatability
-- using protocol number, not name of the version
data Version = Version { name :: String, protocol :: Int } deriving (Generic)
data Players = Players { max :: Int, online :: Int } deriving (Generic)
data Description = Description { text :: String } deriving (Generic)
-- Data record which is passed to the server.
-- It includes all possible responses to the client,
-- in a prepacked state
data Responses = Responses { ping :: ByteString
, start :: ByteString
, denied :: ByteString }
-- Forms JSON object that is sent when somebody pings
-- your server. See an example here:
-- http://wiki.vg/Server_List_Ping
data Ping = Ping { version :: Version
, players :: Players
, description :: Description } deriving (Generic)
instance ToJSON Version
instance ToJSON Players
instance ToJSON Description
instance ToJSON Ping