frame.clj

Bowmap · bowmap.git · Tickets

Branches > main > 125ac6e > files / src / net / bowmap / server / protocol / frame.clj

(ns net.bowmap.server.protocol.frame
  "A framed byte buffer containing one serialized Minecraft protocol packet.
   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)))