4ed8ebd

Bowmap · bowmap.git · Tickets

Branches > main > 4ed8ebd > files

Suffix channel key names with -chan to make clear they are channels

Grahp, 2026-09-24

Commit: 4ed8ebda2f90c4839834defb01fd379ca14c95c4
Parent: 4799394

3 changed files:

src/net/bowmap/server/network/connection.clj modified (view file)

@@ -8,12 +8,12 @@    [java.io IOException]    [java.net Socket])) -(s/def ::connection (s/keys :opt [::clientbound-frames ::serverbound-frames]))+(s/def ::connection (s/keys :opt [::clientbound-frame-chan ::serverbound-frame-chan]))  (defn connection   "Returns a connection from a given java.net.Socket.-   Connection has keys [::clientbound-frames ::serverbound-frames], both-   channels of clientbound and serverbound frames respectively.+   Connection has keys [::clientbound-frame-chan ::serverbound-frame-chan],+   which are channels of clientbound and serverbound frames respectively.    The lifecycles of the client socket and both frame channels are coupled."   [socket]   (let [clientbound-frames (chan 128)@@ -42,5 +42,5 @@           (close! clientbound-frames)           (close! serverbound-frames)           (Socket/.close socket))))-    {::clientbound-frames clientbound-frames-     ::serverbound-frames serverbound-frames}))+    {::clientbound-frame-chan clientbound-frames+     ::serverbound-frame-chan serverbound-frames}))

src/net/bowmap/server/protocol/client.clj modified (view file)

@@ -3,4 +3,4 @@    [clojure.spec.alpha :as s]    [net.bowmap.server.protocol.phase :as phase])) -(s/def ::client (s/keys :opt [::phase/phase ::clientbound-packets]))+(s/def ::client (s/keys :opt [::phase/phase ::clientbound-packet-chan]))

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

@@ -13,27 +13,27 @@    (case in      ::connection/serverbound-frame      (let [[client' packets] (packets/apply-packet client (codec/decode-frame client x))]-       [client' {::client/clientbound-packets packets}])+       [client' {::client/clientbound-packet-chan packets}])       ::client/clientbound-packet-     [client {::connection/clientbound-frames [(codec/encode-packet client x)]}])))+     [client {::connection/clientbound-frame-chan [(codec/encode-packet client x)]}]))) -(defn handle-connection! [{::connection/keys! [serverbound-frames clientbound-frames]}]-  (let [clientbound-packets (chan 1024)]+(defn handle-connection! [{::connection/keys! [serverbound-frame-chan clientbound-frame-chan]}]+  (let [clientbound-packet-chan (chan 1024)]     (io-thread       (loop [client-state (client-step nil)]-        (let [[x ch] (alts!! [serverbound-frames clientbound-packets])+        (let [[x ch] (alts!! [serverbound-frame-chan clientbound-packet-chan])               in (condp = ch-                   serverbound-frames ::connection/serverbound-frame-                   clientbound-packets ::client/clientbound-packet)]+                   serverbound-frame-chan ::connection/serverbound-frame+                   clientbound-packet-chan ::client/clientbound-packet)]           (when (some? x)-            (let [[client' {frames ::connection/clientbound-frames-                            packets ::client/clientbound-packets}]+            (let [[client' {frames ::connection/clientbound-frame-chan+                            packets ::client/clientbound-packet-chan}]                   (client-step client-state in x)]               (doseq [frame frames]-                (put! clientbound-frames frame))+                (put! clientbound-frame-chan frame))               (doseq [packet packets]-                (put! clientbound-packets packet))+                (put! clientbound-packet-chan packet))               (recur client'))))))))  (defn handle-connections!