Skip to content

enet_peer

send(data) function

Send a JavaScript object to this peer on channel 0. The object is serialized to JSON and sent reliably. Throws an error if serialization fails.

data: A JavaScript object to send.

Returns: None

disconnect() function

Request a graceful disconnection from this peer. The connection will close after pending data is sent.

Returns: None

disconnect_now() function

Immediately terminate the connection to this peer, discarding any pending data.

Returns: None

disconnect_later() function

Request a disconnection from this peer after all queued packets are sent.

Returns: None

reset() function

Reset this peer's connection, immediately dropping it and clearing its internal state.

Returns: None

ping() function

Send a ping request to this peer to measure latency.

Returns: None

throttle_configure(interval, acceleration, deceleration) function

Configure the throttling behavior for this peer, controlling how ENet adjusts its sending rate based on packet loss or congestion.

interval: The interval (ms) between throttle adjustments.

acceleration: The factor to increase sending speed when conditions improve.

deceleration: The factor to decrease sending speed when conditions worsen.

Returns: None

timeout(timeout_limit, timeout_min, timeout_max) function

Set timeout parameters for this peer, determining how long ENet waits before considering the connection lost.

timeout_limit: The total time (ms) before the peer is disconnected.

timeout_min: The minimum timeout (ms) used for each timeout attempt.

timeout_max: The maximum timeout (ms) used for each timeout attempt.

Returns: None