52f154f
Branches > client-handling-rewrite > 52f154f > files / deps.edn
Remove unnecessary wrapper fn around packet-framer-xf
Commit: 52f154ff6607740f8c01bc3ecd4d734ef6546eda
Parent: 1e79ddf
1 changed file:
src/net/bowmap/core.clj view file
@@ -15,23 +15,22 @@ (defn packet-framer-xf "Frames bytes from incoming byte arrays and calls 'xf' on ByteBufs of- complete Minecraft protocol packet bytes."- []+ complete Minecraft protocol packet bytes."+ [rf] (let [buf (Unpooled/buffer)]- (fn [rf]- (fn- ([] (rf))- ([res] (rf res))- ([res input]- (ByteBuf/.writeBytes buf input)- (loop [res res]- (if (read/can-read-packet? buf)- (let [len (read/read-varint! buf)- ;; This copy is probably inefficient but fine for now.- res' (rf res (ByteBuf/.copy (ByteBuf/.readRetainedSlice buf len)))]- (ByteBuf/.discardReadBytes buf)- (recur res'))- res)))))))+ (fn+ ([] (rf))+ ([res] (rf res))+ ([res input]+ (ByteBuf/.writeBytes buf input)+ (loop [res res]+ (if (read/can-read-packet? buf)+ (let [len (read/read-varint! buf)+ ;; This copy is probably inefficient but fine for now.+ res' (rf res (ByteBuf/.copy (ByteBuf/.readRetainedSlice buf len)))]+ (ByteBuf/.discardReadBytes buf)+ (recur res'))+ res)))))) (defn handle-packet "Handles one framed Minecraft protocol packet bytes."@@ -44,7 +43,7 @@ (defn client-handler [stream _] (let [client {::state/state ::state/handshaking ::stream stream}]- (d/catch (s/reduce #'handle-packet client (s/transform (packet-framer-xf) stream))+ (d/catch (s/reduce #'handle-packet client (s/transform packet-framer-xf stream)) (fn [e] (println "Exception in client packets:" e)))))