yolkbot
    Preparing search index...

    Class CommIn

    A helper class for unpacking incoming binary data from the server

    Index

    Constructors

    • Creates a new CommIn instance

      Parameters

      • buf: Uint8Array<ArrayBuffer>

        The buffer containing the incoming data

      Returns CommIn

    Methods

    • Gets the number of bytes left to be unpacked from the buffer

      Returns number

      The number of bytes left to be unpacked from the buffer

    • Checks if there is more data to be unpacked from the buffer

      Returns boolean

      Whether there is more data to be unpacked from the buffer

    • Unpacks a double precision floating point value from the buffer, represented as a 32-bit integer where 1048576 units equal 1

      Returns number

      A number with a fractional part, depending on the value in the buffer

    • Unpacks a floating point value from the buffer, represented as a 16-bit integer where 256 units equal 1

      Returns number

      A number with a fractional part, depending on the value in the buffer

    • Unpacks a signed 16-bit integer from the buffer

      Returns number

      A number from -32768 to 32767

    • Unpacks an unsigned 16-bit integer from the buffer

      Returns number

      A number from 0 to 65535

    • Unpacks an unsigned 24-bit integer from the buffer

      Returns number

      A number from 0 to 16777215

    • Unpacks a signed 32-bit integer from the buffer

      Returns number

      A number from -2147483648 to 2147483647

    • Unpacks an unsigned 32-bit integer from the buffer

      Returns number

      A number from 0 to 4294967295

    • Unpacks a signed 8-bit integer from the buffer

      Returns number

      A number from -128 to 127

    • Unpacks an unsigned 8-bit integer from the buffer

      Returns number

      A number from 0 to 255

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

      Parameters

      • maxLen: number = 16383

        The maximum allowed length of the string in characters (not bytes). Defaults to 16383, which is the maximum representable by the length prefix

      Returns string

      A string of up to maxLen characters, depending on the value in the buffer

    • Unpacks a signed radian value from the buffer, represented as a 16-bit integer where 8192 units equal 360 degrees

      Returns number

      A number from -Math.PI to Math.PI

    • Unpacks an unsigned radian value from the buffer, represented as a 24-bit integer where 2097152 units equal 360 degrees

      Returns number

      A number from 0 to 2 * Math.PI

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

      Parameters

      • maxLen: number = 255

        The maximum allowed length of the string in characters (not bytes). Defaults to 255, which is the maximum representable by the length prefix

      Returns string

      A string of up to maxLen characters, depending on the value in the buffer

    Properties

    buffer: Uint8Array

    The buffer containing the incoming data

    idx: number = 0

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