glame/packet

Types

Represents an RCON packet

pub type Packet {
  Packet(size: Int, id: Int, typ: Int, body: BitArray)
}

Constructors

  • Packet(size: Int, id: Int, typ: Int, body: BitArray)
pub type PacketType {
  ServerDataAuth
  ServerDataAuthResponse
  ServerDataExecCommand
  ServerDataResponseValue
}

Constructors

  • ServerDataAuth

    The first packet sent by the client, which is used to authenticate with the server.

  • ServerDataAuthResponse

    A notification of the connection’s current auth status.

  • ServerDataExecCommand

    A packet sent by the client with a command to be executed by the server.

  • ServerDataResponseValue

    A packet sent by the server with the result of a command.

Constants

pub const packet_header_size_bytes: Int = 8

How many bytes the header (i.e., id and type) takes up

pub const packet_padding_size_bytes: Int = 2

How many bytes the padding (i.e., <<0x00, 0x00>>) takes up

Functions

pub fn from_bytes(bytes: BitArray) -> Result(Packet, Error)

Constructs a {Packet} from a {BitArray}

pub fn max_packet_size_bytes() -> Int

Returns the maximum packet size supported by the RCON protocol.

pub fn min_packet_size_bytes() -> Int

Returns the size of a packet with an empty body

pub fn new(
  packet_type: PacketType,
  packet_id: Int,
  body: String,
) -> Result(Packet, Error)

Constructs a new {Packet}

pub fn packet_type_to_int(pt: PacketType) -> Int

Converts a {PacketType} to its integer representation.

pub fn to_bytes(packet: Packet) -> BitArray

Serializes a {Packet} to a {BitArray}

Search Document