Class reference

WebSocketMultiplayerPeer

Inherits MultiplayerPeer

Base class for WebSocket server and client.

Description

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

float handshake_timeout = 3.0

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

Methods

int create_client(String url, TLSOptions tls_client_options = null)

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_server(int port, String bind_address = "*", TLSOptions tls_server_options = null)

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().

String get_peer_address(int id) const

Returns the IP address of the given peer.

int get_peer_port(int id) const

Returns the remote port of the given peer.

Source revision 5592dc3a7a61
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.