a6d28b5
Branches > main > a6d28b5 > files / src / net / bowmap / message_application.clj
use defn! in client message
Commit: a6d28b51262a7fe37303450afd29156a39be2df2
Parent: 60172ff
1 changed file:
src/net/bowmap/network/message/client.clj view file
@@ -2,7 +2,7 @@ (:require [clojure.alpha.spec :as s] [dev.grahp.build :refer [build]]- [dev.grahp.error :refer [adorn get!]]+ [dev.grahp.error :refer [adorn defn! get!]] [net.bowmap.network.message :as msg] [net.bowmap.network.packet :as pk] [net.bowmap.network.packet.types :as t]@@ -280,17 +280,16 @@ :relative-velocity-x :relative-velocity-y :relative-velocity-z :rotate-velocity])]})) -(defn message->packet+(defn! message->packet "Encodes a message into a packet. Like decoding, encoding a packet requires the connection state, as packet ids are not unique across connection states. Several packets are logically the same across states, and can be sent without needing to switch on state." [msg state]- (-> (let [encode-body (get! packets (::msg/id msg))]- (length-prefixed (-> (Unpooled/buffer)- (varint-> (get! message->packet-ids {::msg/id (::msg/id msg) ::state/connection-state state}))- (encode-body msg))))- (adorn "Error while encoding message into packet" {:msg msg :state state})))+ (let [encode-body (get! packets (::msg/id msg))]+ (length-prefixed (-> (Unpooled/buffer)+ (varint-> (get! message->packet-ids {::msg/id (::msg/id msg) ::state/connection-state state}))+ (encode-body msg))))) (s/fdef message->packet :args (s/cat :msg ::msg/message :state ::state/connection-state)