:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml. .. _class_WebSocketMultiplayerPeer: WebSocketMultiplayerPeer ======================== **Inherits:** :ref:`MultiplayerPeer` **<** :ref:`PacketPeer` **<** :ref:`RefCounted` **<** :ref:`Object` 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 :ref:`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 ---------- +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+ | :ref:`PackedStringArray` | :ref:`handshake_headers` | ``PackedStringArray()`` | +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+ | :ref:`float` | :ref:`handshake_timeout` | ``3.0`` | +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+ | :ref:`int` | :ref:`inbound_buffer_size` | ``65535`` | +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+ | :ref:`int` | :ref:`max_queued_packets` | ``2048`` | +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+ | :ref:`int` | :ref:`outbound_buffer_size` | ``65535`` | +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+ | :ref:`PackedStringArray` | :ref:`supported_protocols` | ``PackedStringArray()`` | +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+ Methods ------- +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`create_client` **(** :ref:`String` url, :ref:`bool` verify_tls=true, :ref:`X509Certificate` tls_certificate=null **)** | +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`create_server` **(** :ref:`int` port, :ref:`String` bind_address="*", :ref:`CryptoKey` tls_key=null, :ref:`X509Certificate` tls_certificate=null **)** | +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`WebSocketPeer` | :ref:`get_peer` **(** :ref:`int` peer_id **)** |const| | +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_peer_address` **(** :ref:`int` id **)** |const| | +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_peer_port` **(** :ref:`int` id **)** |const| | +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Property Descriptions --------------------- .. _class_WebSocketMultiplayerPeer_property_handshake_headers: - :ref:`PackedStringArray` **handshake_headers** +-----------+------------------------------+ | *Default* | ``PackedStringArray()`` | +-----------+------------------------------+ | *Setter* | set_handshake_headers(value) | +-----------+------------------------------+ | *Getter* | get_handshake_headers() | +-----------+------------------------------+ The extra headers to use during handshake. See :ref:`WebSocketPeer.handshake_headers` for more details. ---- .. _class_WebSocketMultiplayerPeer_property_handshake_timeout: - :ref:`float` **handshake_timeout** +-----------+------------------------------+ | *Default* | ``3.0`` | +-----------+------------------------------+ | *Setter* | set_handshake_timeout(value) | +-----------+------------------------------+ | *Getter* | get_handshake_timeout() | +-----------+------------------------------+ The maximum time each peer can stay in a connecting state before being dropped. ---- .. _class_WebSocketMultiplayerPeer_property_inbound_buffer_size: - :ref:`int` **inbound_buffer_size** +-----------+--------------------------------+ | *Default* | ``65535`` | +-----------+--------------------------------+ | *Setter* | set_inbound_buffer_size(value) | +-----------+--------------------------------+ | *Getter* | get_inbound_buffer_size() | +-----------+--------------------------------+ The inbound buffer size for connected peers. See :ref:`WebSocketPeer.inbound_buffer_size` for more details. ---- .. _class_WebSocketMultiplayerPeer_property_max_queued_packets: - :ref:`int` **max_queued_packets** +-----------+-------------------------------+ | *Default* | ``2048`` | +-----------+-------------------------------+ | *Setter* | set_max_queued_packets(value) | +-----------+-------------------------------+ | *Getter* | get_max_queued_packets() | +-----------+-------------------------------+ The maximum number of queued packets for connected peers. See :ref:`WebSocketPeer.max_queued_packets` for more details. ---- .. _class_WebSocketMultiplayerPeer_property_outbound_buffer_size: - :ref:`int` **outbound_buffer_size** +-----------+---------------------------------+ | *Default* | ``65535`` | +-----------+---------------------------------+ | *Setter* | set_outbound_buffer_size(value) | +-----------+---------------------------------+ | *Getter* | get_outbound_buffer_size() | +-----------+---------------------------------+ The outbound buffer size for connected peers. See :ref:`WebSocketPeer.outbound_buffer_size` for more details. ---- .. _class_WebSocketMultiplayerPeer_property_supported_protocols: - :ref:`PackedStringArray` **supported_protocols** +-----------+--------------------------------+ | *Default* | ``PackedStringArray()`` | +-----------+--------------------------------+ | *Setter* | set_supported_protocols(value) | +-----------+--------------------------------+ | *Getter* | get_supported_protocols() | +-----------+--------------------------------+ The supported WebSocket sub-protocols. See :ref:`WebSocketPeer.supported_protocols` for more details. Method Descriptions ------------------- .. _class_WebSocketMultiplayerPeer_method_create_client: - :ref:`Error` **create_client** **(** :ref:`String` url, :ref:`bool` verify_tls=true, :ref:`X509Certificate` tls_certificate=null **)** Starts a new multiplayer client connecting to the given ``url``. If ``verify_tls`` is ``false`` certificate validation will be disabled. If specified, the ``tls_certificate`` will be used to verify the TLS host. \ **Note**: It is recommended to specify the scheme part of the URL, i.e. the ``url`` should start with either ``ws://`` or ``wss://``. ---- .. _class_WebSocketMultiplayerPeer_method_create_server: - :ref:`Error` **create_server** **(** :ref:`int` port, :ref:`String` bind_address="*", :ref:`CryptoKey` tls_key=null, :ref:`X509Certificate` tls_certificate=null **)** Starts a new multiplayer server listening on the given ``port``. You can optionally specify a ``bind_address``, and provide a ``tls_key`` and ``tls_certificate`` to use TLS. ---- .. _class_WebSocketMultiplayerPeer_method_get_peer: - :ref:`WebSocketPeer` **get_peer** **(** :ref:`int` peer_id **)** |const| Returns the :ref:`WebSocketPeer` associated to the given ``peer_id``. ---- .. _class_WebSocketMultiplayerPeer_method_get_peer_address: - :ref:`String` **get_peer_address** **(** :ref:`int` id **)** |const| Returns the IP address of the given peer. ---- .. _class_WebSocketMultiplayerPeer_method_get_peer_port: - :ref:`int` **get_peer_port** **(** :ref:`int` id **)** |const| Returns the remote port of the given peer. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`