frame.clj
Branches > main > f5d10a8 > files / src / net / bowmap / server / protocol / frame.clj
(ns net.bowmap.server.protocol.frame
"A framed byte buffer containing one serialized Minecraft protocol packet.
A frame contains the packet's numeric id and payload.
Frames are not length-prefixed.
See https://minecraft.wiki/w/Java_Edition_protocol/Packets for the format."
(:require
[clojure.spec.alpha :as s])
(:import
[io.netty.buffer ByteBuf Unpooled]))
(s/def ::frame #(instance? ByteBuf %))
(defn frame
"Returns an empty frame, or a frame containing the bytes of an array."
([] (Unpooled/buffer))
([arr] (Unpooled/wrappedBuffer arr)))