Index · Object → RefCounted → PacketPeer → MultiplayerPeer → WebSocketMultiplayerPeer

WebSocketMultiplayerPeer

Base class for WebSocket server and client.

Class 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

var handshake_headers: PackedStringArray = PackedStringArray()

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

var handshake_timeout: float = 3.0

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

var inbound_buffer_size: int = 65535

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

var max_queued_packets: int = 4096

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

var outbound_buffer_size: int = 65535

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

var supported_protocols: PackedStringArray = PackedStringArray()

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

Inherited from MultiplayerPeer (3)
Inherited from PacketPeer (1)

Methods

func create_client(url: String, tls_client_options: TLSOptions = null) -> Error

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://.

func create_server(port: int, bind_address: String = "*", tls_server_options: TLSOptions = null) -> Error

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

func get_peer(peer_id: int) -> WebSocketPeer

Returns the WebSocketPeer associated to the given peer_id.

func get_peer_address(id: int) -> String

Returns the IP address of the given peer.

func get_peer_port(id: int) -> int

Returns the remote port of the given peer.

Inherited from MultiplayerPeer (11)
func close() -> void
func disconnect_peer(peer: int, force: bool = false) -> void
func get_unique_id() -> int
func poll() -> void
func set_target_peer(id: int) -> void
Inherited from PacketPeer (6)
func get_packet_error() -> Error
func get_var(allow_objects: bool = false) -> Variant
func put_packet(buffer: PackedByteArray) -> Error
func put_var(var: Variant, full_objects: bool = false) -> Error
Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from MultiplayerPeer (2)
signal peer_connected(id: int)
Inherited from Object (2)