yolkbot
    Preparing search index...

    Class CommOut

    Allows you to send data to the game server

    Index

    Constructors

    • Creates a new CommOut instance

      Parameters

      • size: number = 16384

        The size of the buffer to create, in bytes. Defaults to 16384, which should be large enough for any single packet

      Returns CommOut

    Methods

    • Packs a double precision floating point value into the buffer as a 32-bit integer where 1048576 units equal 1

      Parameters

      • val: number

        A number with a fractional part, depending on the desired precision

      Returns void

    • Packs a floating point value into the buffer as a 16-bit integer where 256 units equal 1

      Parameters

      • val: number

        A number with a fractional part, depending on the desired precision

      Returns void

    • Packs an unsigned 8-bit integer into the buffer

      Parameters

      • val: number

        A number from 0 to 255

      Returns void

    • Packs a signed 24-bit integer into the buffer

      Parameters

      • val: number

        A number from -8388608 to 8388607

      Returns void

    • Packs an unsigned 24-bit integer into the buffer

      Parameters

      • val: number

        A number from 0 to 16777215

      Returns void

    • Packs a signed 8-bit integer into the buffer

      Parameters

      • val: number

        A number from -128 to 127

      Returns void

    • Packs a string into the buffer, prefixed with an unsigned 16-bit integer representing the length of the string in characters (not bytes)

      Parameters

      • str: string

        The string to pack. If not a string, it will be converted to an empty string. If longer than 65535 characters, it will be truncated

      Returns void

    • Packs a radian value into the buffer as a signed 16-bit integer where 8192 units equal 360 degrees

      Parameters

      • val: number

        A number from -Math.PI to Math.PI

      Returns void

    • Packs a radian value into the buffer as a signed 24-bit integer where 2097152 units equal 360 degrees

      Parameters

      • val: number

        A number from -Math.PI to Math.PI

      Returns void

    • Packs a string into the buffer, prefixed with an unsigned 8-bit integer representing the length of the string in characters (not bytes)

      Parameters

      • str: string

        The string to pack. If not a string, it will be converted to an empty string. If longer than 255 characters, it will be truncated

      Returns void

    • Sends the packed data to the server through the given WebSocket or WebSocket-like object with a send method

      Parameters

      • ws: { send: (data: Uint8Array<ArrayBuffer>) => void } | WebSocket

        A WebSocket or any object with a send method that accepts a Uint8Array or ArrayBuffer

      Returns void

    Properties

    arrayBuffer: ArrayBuffer

    The ArrayBuffer containing the outgoing data

    idx: number = 0

    The current index in the buffer (automatically updated by packing methods)

    view: DataView

    A DataView for writing data to the arrayBuffer