Table of Contents

Class WebSocketMultiplayerPeer

Base class for WebSocket server and client.

Inheritance
WebSocketMultiplayerPeer

Remarks

Base class for WebSocket server and client, allowing them to be used as multiplayer peer for the MultiplayerAPI.

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.

Properties

handshake_headers

The extra headers to use during handshake. See handshake_headers for more details.

var handshake_headers : PackedStringArray = PackedStringArray()

Property Value

PackedStringArray

Remarks

handshake_timeout

The maximum time each peer can stay in a connecting state before being dropped.

var handshake_timeout : float = 3.0

Property Value

float

Remarks

  • void set_handshake_timeout(float value)
  • float get_handshake_timeout

inbound_buffer_size

The inbound buffer size for connected peers. See inbound_buffer_size for more details.

var inbound_buffer_size : int = 65535

Property Value

int

Remarks

  • void set_inbound_buffer_size(int value)
  • int get_inbound_buffer_size

max_queued_packets

The maximum number of queued packets for connected peers. See max_queued_packets for more details.

var max_queued_packets : int = 4096

Property Value

int

Remarks

  • void set_max_queued_packets(int value)
  • int get_max_queued_packets

outbound_buffer_size

The outbound buffer size for connected peers. See outbound_buffer_size for more details.

var outbound_buffer_size : int = 65535

Property Value

int

Remarks

  • void set_outbound_buffer_size(int value)
  • int get_outbound_buffer_size

supported_protocols

The supported WebSocket sub-protocols. See supported_protocols for more details.

var supported_protocols : PackedStringArray = PackedStringArray()

Property Value

PackedStringArray

Remarks

Methods

create_client(String, TLSOptions)

Starts a new multiplayer client connecting to the given url. TLS certificates will be verified against the hostname when connecting using the wss:// protocol. You can pass the optional tls_client_options parameter to customize the trusted certification authorities, or disable the common name verification. See TLSOptions.client and TLSOptions.client_unsafe.

Note: It is recommended to specify the scheme part of the URL, i.e. the url should start with either ws:// or wss://.

int create_client(String url, TLSOptions tls_client_options)

Parameters

url String
tls_client_options TLSOptions

create_server(int, String, TLSOptions)

Starts a new multiplayer server listening on the given port. You can optionally specify a bind_address, and provide valid tls_server_options to use TLS. See TLSOptions.server.

int create_server(int port, String bind_address, TLSOptions tls_server_options)

Parameters

port int
bind_address String
tls_server_options TLSOptions

get_peer(int)

Qualifiers: const

Returns the WebSocketPeer associated to the given peer_id.

WebSocketPeer get_peer(int peer_id)

Parameters

peer_id int

get_peer_address(int)

Qualifiers: const

Returns the IP address of the given peer.

String get_peer_address(int id)

Parameters

id int

get_peer_port(int)

Qualifiers: const

Returns the remote port of the given peer.

int get_peer_port(int id)

Parameters

id int