9aaf2d3

Bowmap · bowmap.git · Tickets

Branches > main > 9aaf2d3 > files

Replace handle.clj player value with a connection uuid

Grahp, 2026-09-29

Commit: 9aaf2d3be01d168813c6bfcb2954eb74540612b4
Parent: 339bb4d

2 changed files:

src/net/bowmap/server/game/handle.clj modified (view file)

@@ -7,33 +7,29 @@    [net.bowmap.server.protocol.serverbound-packets :as serverbound]))  (defmulti handle-packet-  "Handles a packet from a player, returning [player' [packets*]?]."-  (fn [player packet]+  "Handles a packet from a player given their connection uuid.+   Returning a sequence of response packets."+  (fn [connection-uuid packet]     (::packet/id packet))) -(defmethod handle-packet :default [player _] [player])+(defmethod handle-packet :default [_ _]) -(defmethod handle-packet ::serverbound/status-request [player _]-  [player-   [{::packet/id ::clientbound/status-response-     ::p/version-name "26.2"-     ::p/protocol 776-     ::p/motd {::component/text "Bowmap!"-               ::component/color "#9f9f9f"}-     ::p/online-player-count 0-     ::p/max-player-count 1000}]])+(defmethod handle-packet ::serverbound/status-request [_ _]+  [{::packet/id ::clientbound/status-response+    ::p/version-name "26.2"+    ::p/protocol 776+    ::p/motd {::component/text "Bowmap!"+              ::component/color "#9f9f9f"}+    ::p/online-player-count 0+    ::p/max-player-count 1000}]) -(defmethod handle-packet ::serverbound/ping-request [player {::p/keys! [timestamp]}]-  [player-   [{::packet/id ::clientbound/pong-response-     ::p/timestamp timestamp}]])+(defmethod handle-packet ::serverbound/ping-request [_ {::p/keys! [timestamp]}]+  [{::packet/id ::clientbound/pong-response+    ::p/timestamp timestamp}]) -(defmethod handle-packet ::serverbound/login-start [player {::p/keys! [uuid username]}]-  [(assoc player-          ::p/uuid uuid-          ::p/username username)-   [{::packet/id ::clientbound/login-success-     ::p/game-profile {::p/uuid uuid-                       ::p/username username-                       ::p/game-profile-properties []}-     ::p/session-uuid (random-uuid)}]])+(defmethod handle-packet ::serverbound/login-start [connection-uuid {::p/keys! [uuid username]}]+  [{::packet/id ::clientbound/login-success+    ::p/game-profile {::p/uuid uuid+                      ::p/username username+                      ::p/game-profile-properties []}+    ::p/session-uuid connection-uuid}])

src/net/bowmap/server/runtime/connections.clj modified (view file)

@@ -20,7 +20,7 @@  (defn handle-connection! [connection]   (let [client-atom (atom {::phase/phase ::phase/handshaking})-        player (atom {})+        connection-uuid (random-uuid)         send-packet! (fn [packet]                        (let [frame (serialize/encode-packet @client-atom packet)]                          (connection/send-frame! connection frame)))]@@ -30,8 +30,7 @@               packet (serialize/decode-frame client frame)               client' (apply-packet client packet)]           (assert (compare-and-set! client-atom client client'))-          (let [[player' packets] (handle/handle-packet @player packet)]-            (reset! player player')+          (let [packets (handle/handle-packet connection-uuid packet)]             (run! send-packet! packets)))         (recur)))))