6f4938c
Branches > refactor/use-spec-1 > 6f4938c > files
Remove buffer from packet encoding
Commit: 6f4938ca8320a25f615b6dd87d778f1d34a99a86
Parent: e6445b6
2 changed files:
src/net/bowmap/core.clj view file
@@ -27,7 +27,7 @@ (vswap! client assoc ::state/state state)) (when response ;; TODO this can also throw...- (encode-packet! (Unpooled/buffer) response (::state/state @client))))+ (encode-packet! response (::state/state @client)))) (ByteBuf/.discardReadBytes buf)))) (defn client-handler [s _]src/net/bowmap/packets/client.clj view file
@@ -81,18 +81,13 @@ (comment (packets ::status-response)) -(defn encode-packet! [buf pk state]+(defn encode-packet! [pk state] {:pre [(packet? pk)]} (let [id (assert! (numeric-id state (::pk/id pk))) encoder (assert! (packet-encoder pk)) data-buf (-> (Unpooled/buffer) (write-varint! id) (encoder pk))]- (write-varint! buf (ByteBuf/.writerIndex data-buf))- (ByteBuf/.writeBytes buf data-buf)))--(comment- (.array (encode-packet! (Unpooled/buffer)- {::pk/id ::pong-response- :timestamp 42}- ::state/status)))+ (-> (Unpooled/buffer)+ (write-varint! (ByteBuf/.writerIndex data-buf))+ (ByteBuf/.writeBytes data-buf))))