message.clj
Branches > main > 2817adb > files / src / net / bowmap / network / message.clj
(ns net.bowmap.network.message
(:require
[clojure.alpha.spec :as s]))
; TODO update comments they are old
(s/def ::id qualified-keyword?)
; Represents a deserialized Minecraft protocol packet
; See net.bowmap.packets.client and net.bowmap.packets.server for those.
; In serialized form, uncompressed packets have the following structure:
; - A length varint (see net.bowmap.packet.types)
; - A numeric id varint (::numeric-id)
; - The rest of the packet data, which depends on the ID (and connection state)
; Each protocol connection state (see net.bowmap.client.state) has its own set
; of numeric ids for clientbound and serverbound packets, so there isn't a
; direct function of numeric ids to '::id's, or vice versa.
; See 'net.bowmap.packet.client/packet-ids' and 'net.bowmap.packet.server/packet-ids'.
; Packet maps will also contain other fields as defined in the 'packets' var of the above namespaces
(s/def ::message (s/schema [::id]))
; This could actually check the id and fields to see if it's valid if there's any point in that
(defn message? [x]
(boolean (find x ::id)))