Ping🔗

Inherits: Timer

This defines a ping manager.

Description🔗

When added to your scene and connect the synchronized signal to your custom handler in order to receive ping updates on a regular basis (as defined by ping_interval and synchronize the state for each peer.

func _ready() -> void:
    $Ping.synchronized.connect(_on_ping_sync)

func _on_ping_sync(state: Dictionary) -> void:
    for peer_id in state:
        print("peer `%s` latency is %d ms" % [peer_id, state[peer_id]])

Properties🔗

int

ping_history

8

Dictionary

_state

{}

Dictionary

_infos

{}

Array

_pings

[]

int

_last_ping

0

Methods🔗

void

_ready()

void

_on_timeout()

void

clear_pings()

void

set_ping_history(value: int)

void

_add_peer(peer_id: int)

void

_del_peer(peer_id: int)

void

_ping(time: int)

void

_pong(time: int)

void

_synchronize(state: Dictionary)


Signals🔗

synchronized(state: Dictionary) 🔗

Emitted when the state is synchronized.


Property Descriptions🔗

int ping_history = 8 🔗

  • void set_ping_history(value: int)

The size of the ping history buffer used to store past ping times for each client.


Dictionary _state = {} 🔗

The ping state being synchronized to connected peers


Dictionary _infos = {} 🔗

The dictionary of PingInfo for each connected peer id


Array _pings = [] 🔗

The array of times when a ping request occured


int _last_ping = 0 🔗

There is currently no description for this property. Please help us by contributing one!


Method Descriptions🔗

void _ready() 🔗

There is currently no description for this method. Please help us by contributing one!


void _on_timeout() 🔗

There is currently no description for this method. Please help us by contributing one!


void clear_pings() 🔗

Clears the ping history array.


void set_ping_history(value: int) 🔗

Sets the size of the ping history buffer and clears existing ping data.


void _add_peer(peer_id: int) 🔗

Adds a new peer to the registry


void _del_peer(peer_id: int) 🔗

Deletes a peer from the registry


void _ping(time: int) 🔗

There is currently no description for this method. Please help us by contributing one!


void _pong(time: int) 🔗

There is currently no description for this method. Please help us by contributing one!


void _synchronize(state: Dictionary) 🔗

There is currently no description for this method. Please help us by contributing one!