growtopia.wasm
    Preparing search index...

    Class Peer

    Represents a connected remote ENet peer endpoint. Provides methods for transmitting packets, querying state, and managing connection lifecycle.

    Index
    • Instantiates a new Peer wrapper.

      Parameters

      • host: Host

        Underlying WebAssembly Host instance.

      • id: number

        Numeric peer ID.

      Returns Peer

    id: number

    The unique numeric ID assigned to this peer by the ENet host.

    • get ip(): string

      Gets the remote IP address of the peer.

      Returns string

    • get port(): number

      Gets the remote UDP port number of the peer.

      Returns number

    • get rtt(): number

      Gets the current round-trip time (RTT) in milliseconds.

      Returns number

    • get state(): number

      Gets the current ENet connection state for this peer.

      Returns number

    • Initiates a graceful disconnect request for this peer.

      Parameters

      • data: number = 0

        Optional integer disconnect code.

      Returns void

    • Schedules a disconnect for this peer after all queued outgoing packets are delivered.

      Parameters

      • data: number = 0

        Optional integer disconnect code.

      Returns void

    • Forces an immediate abrupt disconnect for this peer without waiting for acknowledgments.

      Parameters

      • data: number = 0

        Optional integer disconnect code.

      Returns void

    • Sends a ping request to update peer round-trip time calculations.

      Returns void

    • Resets peer connection state immediately, clearing allocated core resources.

      Returns void

    • Sends a WebAssembly ENet packet to the peer.

      Parameters

      • packet: Packet

        ENet Packet instance to transmit.

      • channel: number = 0

        ENet channel ID (defaults to 0).

      Returns void

    • Encapsulates raw byte data into an ENet Packet and transmits it to the peer.

      Parameters

      • data: Uint8Array

        Byte array containing payload data.

      • channel: number = 0

        ENet channel ID (defaults to 0).

      • flags: number = 1

        Reliability flag (0 = Unreliable, 1 = Reliable, 2 = Unsequenced).

      Returns void