0cc811b
Branches > main > 0cc811b > files
Improve readability of connections.clj
Commit: 0cc811b57eb1c619f44dc39b6da9849d3efb3f68
Parent: 208a969
1 changed file:
src/net/bowmap/server/runtime/connections.clj view file
@@ -19,16 +19,17 @@ client))) (defn handle-connection! [connection]- (let [client (atom {::phase/phase ::phase/handshaking})+ (let [client-atom (atom {::phase/phase ::phase/handshaking}) player (atom {}) send-packet! (fn [packet]- (connection/send-frame! connection (serialize/encode-packet @client packet)))]+ (let [frame (serialize/encode-packet @client-atom packet)]+ (connection/send-frame! connection frame)))] (loop [] (when-some [frame (connection/receive-frame!! connection)]- (let [c @client- packet (serialize/decode-frame c frame)- client' (apply-packet c packet)]- (assert (compare-and-set! client c client'))+ (let [client @client-atom+ 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') (run! send-packet! packets)))