ENetPacketPeer

Inherits: PacketPeer < RefCounted < Object

A wrapper class for an ENetPeer.

Description

A PacketPeer implementation representing a peer of an ENetConnection.

This class cannot be instantiated directly but can be retrieved during ENetConnection.service or via ENetConnection.get_peers.

Note: When exporting to Android, make sure to enable the INTERNET permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.

Tutorials

Methods

int

get_channels ( ) const

String

get_remote_address ( ) const

int

get_remote_port ( ) const

PeerState

get_state ( ) const

float

get_statistic ( PeerStatistic statistic )

bool

is_active ( ) const

void

peer_disconnect ( int data=0 )

void

peer_disconnect_later ( int data=0 )

void

peer_disconnect_now ( int data=0 )

void

ping ( )

void

ping_interval ( int ping_interval )

void

reset ( )

Error

send ( int channel, PackedByteArray packet, int flags )

void

set_timeout ( int timeout, int timeout_min, int timeout_max )

void

throttle_configure ( int interval, int acceleration, int deceleration )


Enumerations

enum PeerState:

PeerState STATE_DISCONNECTED = 0

The peer is disconnected.

PeerState STATE_CONNECTING = 1

The peer is currently attempting to connect.

PeerState STATE_ACKNOWLEDGING_CONNECT = 2

The peer has acknowledged the connection request.

PeerState STATE_CONNECTION_PENDING = 3

The peer is currently connecting.

PeerState STATE_CONNECTION_SUCCEEDED = 4

The peer has successfully connected, but is not ready to communicate with yet (STATE_CONNECTED).

PeerState STATE_CONNECTED = 5

The peer is currently connected and ready to communicate with.

PeerState STATE_DISCONNECT_LATER = 6

The peer is slated to disconnect after it has no more outgoing packets to send.

PeerState STATE_DISCONNECTING = 7

The peer is currently disconnecting.

PeerState STATE_ACKNOWLEDGING_DISCONNECT = 8

The peer has acknowledged the disconnection request.

PeerState STATE_ZOMBIE = 9

The peer has lost connection, but is not considered truly disconnected (as the peer didn't acknowledge the disconnection request).


enum PeerStatistic:

PeerStatistic PEER_PACKET_LOSS = 0

Mean packet loss of reliable packets as a ratio with respect to the PACKET_LOSS_SCALE.

PeerStatistic PEER_PACKET_LOSS_VARIANCE = 1

Packet loss variance.

PeerStatistic PEER_PACKET_LOSS_EPOCH = 2

The time at which packet loss statistics were last updated (in milliseconds since the connection started). The interval for packet loss statistics updates is 10 seconds, and at least one packet must have been sent since the last statistics update.

PeerStatistic PEER_ROUND_TRIP_TIME = 3

Mean packet round trip time for reliable packets.

PeerStatistic PEER_ROUND_TRIP_TIME_VARIANCE = 4

Variance of the mean round trip time.

PeerStatistic PEER_LAST_ROUND_TRIP_TIME = 5

Last recorded round trip time for a reliable packet.

PeerStatistic PEER_LAST_ROUND_TRIP_TIME_VARIANCE = 6

Variance of the last trip time recorded.

PeerStatistic PEER_PACKET_THROTTLE =