5472b9d
Branches > client-handling-rewrite > 5472b9d > files
Dcoument and rename encode-packet
Commit: 5472b9d14f4217e4a97befa3496bf302e8f1d297
Parent: cbd1421
2 changed files:
src/net/bowmap/core.clj view file
@@ -5,7 +5,7 @@ [net.bowmap.client.state :as state] [net.bowmap.codecs.read :as read] [net.bowmap.packet-handling :as handle]- [net.bowmap.packets.client :refer [encode-packet!]]+ [net.bowmap.packets.client :refer [encode-packet]] [net.bowmap.packets.server :as sp]) (:import [io.netty.buffer ByteBuf Unpooled]@@ -27,17 +27,16 @@ {:keys [::state/state response]} (handle/handle-packet pk client) client (cond-> client state (assoc ::state/state state))] (when response- (let [pk (encode-packet! response (::state/state client))]- (s/put! stream pk)))+ (s/put! stream (encode-packet response (::state/state client)))) (ByteBuf/.discardReadBytes buf) (recur client)) client)))) -(defn client-handler [s _]+(defn client-handler [stream _] (let [client {::state/state ::state/handshaking ::buf (Unpooled/buffer)- ::stream s}]- (s/reduce #'handle-bytes client s)))+ ::stream stream}]+ (s/reduce #'handle-bytes client stream))) (defn start-server! [] (tcp/start-server #'client-handlersrc/net/bowmap/packets/client.clj view file
@@ -73,7 +73,9 @@ (defn packet-encoder [pk] (packets (::pk/id pk))) -(defn encode-packet! [pk state]+(defn encode-packet+ "Encodes packet 'pk' into a ByteBuf of the packet bytes."+ [pk state] {:pre [(packet? pk)]} (let [id (assert! (numeric-id state (::pk/id pk))) encoder (assert! (packet-encoder pk))