a6d1abb
Branches > refactor/use-spec-1 > a6d1abb > files
Specs
Commit: a6d1abbf0f3a9b69b2b99ba2b0a474aa199296e6
Parent: 8172c84
6 changed files:
src/net/bowmap/network/message.clj view file
@@ -1,13 +1,13 @@ (ns net.bowmap.network.message (:require [clojure.alpha.spec :as s]- [dev.grahp.spec :as ss]))+ [dev.grahp.spec :as S])) -(ss/def ::id+(S/def ::id "The id of a message. See the serverbound and clientbound packet definitions for the names." qualified-keyword?) -(ss/def ::message+(S/def ::message "Represents a logical message map (object) from client to/from server. 'Packet' is used to refer to a serialized message" (s/schema [::id]))src/net/bowmap/network/packet.clj view file
@@ -1,11 +1,11 @@ (ns net.bowmap.network.packet (:require- [dev.grahp.spec :as ss]))+ [dev.grahp.spec :as S])) ; The serialized form of a message, called a packet by everyone else :p ; See https://minecraft.wiki/w/Java_Edition_protocol/Packets -(ss/def ::id+(S/def ::id "Protocol id of a packet, i.e. 0x00, 0x80, etc. Numeric ids are NOT unique across connection states! See the wiki" pos-int?)src/net/bowmap/network/packet/read.clj view file
@@ -4,7 +4,7 @@ See https://minecraft.wiki/w/Java_Edition_protocol/Packets#Data_types" (:require [dev.grahp.error :refer [adorn ensure-not! raise]]- [dev.grahp.spec :as spec]+ [dev.grahp.spec :as S] [net.bowmap.network.packet.types :as t]) (:import [io.netty.buffer ByteBuf]@@ -82,7 +82,7 @@ ; Table is a keyword? (defn ->table [table-fields] ; TODO other one too- (let [table (spec/ensure-conform ::t/table table-fields)]+ (let [table (S/ensure-conform ::t/table table-fields)] (fn [buf] (reduce (fn [acc {::t/keys [field codec]}] (adorn (if-some [x (codec buf)]src/net/bowmap/network/packet/write.clj view file
@@ -6,7 +6,7 @@ [clojure.data.json :as json] [clojure.set :as set] [dev.grahp.error :refer [adorn raise]]- [dev.grahp.spec :as spec]+ [dev.grahp.spec :as S] [net.bowmap.network.packet.types :as t]) (:import [io.netty.buffer ByteBuf]@@ -197,6 +197,6 @@ (writer buf x)))) (defn table-> [t]- (let [table (spec/ensure-conform ::t/table t)]+ (let [table (S/ensure-conform ::t/table t)] (fn [buf m] (write-table! buf table m))))src/net/bowmap/network/state.clj view file
@@ -1,4 +1,7 @@ (ns net.bowmap.network.state- (:require [clojure.alpha.spec :as s]))+ (:require+ [dev.grahp.spec :as S])) -(s/def ::state #{::handshaking ::status ::login ::config ::play})+(S/def ::state+ "Network connection state, see https://minecraft.wiki/w/Java_Edition_protocol/Packets"+ #{::handshaking ::status ::login ::config ::play})src/net/bowmap/packet.clj view file
@@ -0,0 +1 @@+(ns net.bowmap.packet)