Skip to main content

Crate signal_fish_client_godot

Crate signal_fish_client_godot 

Source
Expand description

Godot 4.5 WebSocketPeer transport for native and web exports.

Godot owns the platform WebSocket implementation. This transport advances it from Transport::poll_send, Transport::poll_recv, and Transport::poll_close, making it suitable for SignalFishPollingClient in a Node’s _process callback. It contains no GDScript or Emscripten WebSocket FFI.

This crate is versioned in lockstep with signal-fish-client, supports godot-rust 0.4.5 through 0.5.x, and requires Rust 1.94. Applications should select one exact godot version in that range so their Gd<WebSocketPeer> has the same type identity as the adapter’s public API.

§Outbound frame bound

Godot refuses to buffer an outbound message once the peer’s outbound buffer would overflow, so a single frame larger than outbound_buffer_size (65,535 bytes by default) is never admitted on native builds — and one at or above that size on web exports. Such a frame parks as Pending, growing only the capacity diagnostics. SDK-created peers keep that legacy outbound default and raise only the inbound buffer; keep game payloads under ~64 KiB, or construct your own peer with a raised outbound buffer and wrap it with GodotWebSocketTransport::from_peer.

§Inbound queue bounds and platform divergence

Godot bounds its inbound queue by both bytes (inbound_buffer_size) and packet count (max_queued_packets, engine default 4,096). What happens at the bound diverges by platform: Godot’s web backend silently drops newly arriving frames (the adapter receives no error it could surface), while the native backend stops reading and backpressures the connection — delivery stalls (server writes block, latency climbs) until the application drains queued packets. SDK-created peers therefore raise the packet cap from 4,096 to 65,536 alongside the 8 MiB inbound byte buffer: preventing silent drops on web and keeping natively stalled delivery rare. The limits remain independent: enough very small frames can still reach the packet cap first. GodotWebSocketTransport::from_peer preserves whatever the application configured — raise max_queued_packets yourself if a caller-owned peer must absorb large inbound bursts on web.

Three further engine-imposed limits cannot be worked around adapter-side:

  • Native tail frames: Godot’s native build makes buffered packets inaccessible the moment the peer leaves the OPEN state, so final application frames that arrived just before the peer’s CLOSE are delivered by web exports but discarded natively.
  • Synthesized close codes: when the engine terminates the connection itself (protocol error, oversized message), it reports a locally synthesized status code (for example 1002/1007/1009) as if it were a wire close frame; the JS wasClean flag is discarded on web. Close metadata in Transport::close_info therefore cannot perfectly distinguish a genuine peer close from a locally synthesized one.
  • Unvalidated native text frames: Godot’s native backend does not validate text-frame UTF-8, so a corrupt text packet from the network reaches the adapter as raw bytes. Because TransportFrame::Text cannot represent invalid UTF-8, such a packet surfaces a terminal TransportReceive error instead of being lossily substituted, which ends the stream at the driver. Web exports are immune: browsers validate text frames before delivery.

Structs§

GodotWebSocketOptions
Construction options for GodotWebSocketTransport.
GodotWebSocketTransport
A main-thread Transport backed by Godot 4.5’s WebSocketPeer.

Enums§

GodotBackpressurePolicy
Godot outbound admission strategy.