53ac1a6
Branches > client-handling-rewrite > 53ac1a6 > files
fix client errors
Commit: 53ac1a6d84b3bdb33babba9c8419def19a9c8e4a
Parent: 6266640
2 changed files:
src/dev/grahp/error.clj view file
@@ -74,6 +74,10 @@ (defmacro get! "Same as '(get k m)', but throws an error when the key is not present"- ([m k] (get! ~m ~k "Failed get!, no such key in map!"))+ ([m k] `(get! ~m ~k "Failed get!, no such key in map!")) ([m k msg]- `(get ~m ~k (raise ~msg {:map ~m :key ~k}))))+ `(let [m# ~m+ k# ~k]+ (if (contains? m# k#)+ (get m# k#)+ (raise ~msg {:map m# :key k#})))))src/net/bowmap/network/message/client.clj view file
@@ -27,6 +27,7 @@ i])) ; TODO docstrings!+; And spec input? (defn build-packets [registry] (reduce (fn [acc [packet-id table]] (assoc acc packet-id (table-> table)))@@ -34,10 +35,10 @@ ; TODO docstring? (def ^{:spec (s/map-of (s/schema [::state/connection-state ::msg/id]) ::pk/id)}- packet-ids+ message->packet-ids ; Packet ids could map directly to numeric-ids and be stateless, ; but some packets have duplicates across connection states that you'd want to handle in the same way.- ; If it turns out that I don't end up handling packets in this way, then packet ids could map directly to numeric ids."+ ; If it turns out that I don't end up handling packets in this way, then packet ids could map directly to numeric ids. (build-packet-ids {::state/status [::status-response@@ -268,8 +269,8 @@ same across connection states, and so can be sent without needing to switch on the connection state." [msg state]- (-> (let [encode-body (get! packets msg)]+ (-> (let [encode-body (get! packets (::msg/id msg))] (length-prefixed (-> (Unpooled/buffer)- (varint-> (get! packet-ids msg state))+ (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})))