73c8e36
Branches > facts > 73c8e36 > files / README.md
Make client key in packet handlers optional
Commit: 73c8e36d4cea0bf4529035243f6180e819e3eb69
Parent: 080b6b8
1 changed file:
src/net/bowmap/network/handle.clj view file
@@ -20,8 +20,8 @@ (fn [client packet] (::pk/id packet))) -(defmethod handle-packet :default [client _]- {:client client})+(defmethod handle-packet :default [_ _]+ {}) (defmethod handle-packet ::serverbound/handshaking [client pk] (let [{:keys! [intent protocol]} pk]@@ -30,13 +30,11 @@ :protocol-id protocol)})) (defmethod handle-packet ::serverbound/status-request [client _]- {:client client- :facts [{::fact/id ::fact/server-list-requested+ {:facts [{::fact/id ::fact/server-list-requested ::client/client client}]}) (defmethod handle-packet ::serverbound/ping-request [client pk]- {:client client- :packets [{::pk/id ::clientbound/pong-response+ {:packets [{::pk/id ::clientbound/pong-response :timestamp (:timestamp pk)}]}) (defmethod handle-packet ::serverbound/login-start [client pk]@@ -60,8 +58,7 @@ ; Yield facts from this as well and send 'em in! ; Or well, this can be retried so just use the dosync (defmethod handle-packet ::serverbound/known-packs [client _]- {:client client- :packets (conj (vec (registry/registry-packets))+ {:packets (conj (vec (registry/registry-packets)) {::pk/id ::clientbound/update-tags :tagged-registries [{:registry "minecraft:block" :tags [{:tag-name "bowmap:infiniburn"@@ -171,7 +168,7 @@ (dosync ; May want sync-facts vs. async-facts? ; The facts themselves shouldn't care but the handler might- (let [{:keys! [client] :keys [packets facts keepalive?]} (handle-packet @client-ref packet)]+ (let [{:keys [client packets facts keepalive?] :or {client @client-ref}} (handle-packet @client-ref packet)] (ref-set client-ref client) (let [{:keys! [::connection/connection ::state/connection-state]} @client-ref] (doseq [pk packets]