Skip to content

Client API

Valk edited this page Feb 2, 2026 · 5 revisions

Everything below is what GodotClient exposes as an API to you.

Config

uint PingIntervalMs - Sets an interval at which pings will be sent to a peer. Pings are used both to monitor the liveness of the connection and also to dynamically adjust the throttle during periods of low traffic so that the throttle has reasonable responsiveness during traffic spikes.

uint PeerTimeoutMs – The maximum time the peer will wait (based on the average round‑trip time plus a tolerance) for a reliable packet to be acknowledged before it is considered timed‑out and the connection is closed.

uint PeerTimeoutMinimumMs – The shortest period that must elapse after sending a reliable packet before a timeout can trigger; even if the calculated timeout hasn’t been reached, the peer won’t disconnect before this minimum has passed.

uint PeerTimeoutMaximumMs – The absolute upper bound on waiting for acknowledgments; if a reliable packet remains unacknowledged for longer than this period, the peer disconnects regardless of any other timeout calculations.

Events

event Action Connected - Client connected to the server.

event Action<DisconnectOpcode> Disconnected - Client disconnected from the server.

event Action Timedout - Client timed out from the server.

Virtuals

virtual void OnConnect(Event netEvent) - The client connects to the server.

virtual void OnDisconnect(Event netEvent) - The client disconnects from the server.

virtual void OnTimeout(Event netEvent) - The client timedout.

Methods

bool IsConnected - Returns true if the client is connected to the server and false otherwise.

void RegisterPacketHandler<TPacket>(Action<TPacket> handler) - Register and do something when a ServerPacket is received by the client.

void Send(ClientPacket packet) - Send a packet from the client to the server.

void Log(object message) - Logs a message as the client. Using GD.Print may lead to crashes if printing from multiple threads so always use Log.

Clone this wiki locally