class_websocketmultiplayerpeer.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml.
  6. .. _class_WebSocketMultiplayerPeer:
  7. WebSocketMultiplayerPeer
  8. ========================
  9. **Inherits:** :ref:`MultiplayerPeer<class_MultiplayerPeer>` **<** :ref:`PacketPeer<class_PacketPeer>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Base class for WebSocket server and client.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Base class for WebSocket server and client, allowing them to be used as multiplayer peer for the :ref:`MultiplayerAPI<class_MultiplayerAPI>`.
  15. \ **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.
  16. .. rst-class:: classref-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+
  22. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`handshake_headers<class_WebSocketMultiplayerPeer_property_handshake_headers>` | ``PackedStringArray()`` |
  23. +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+
  24. | :ref:`float<class_float>` | :ref:`handshake_timeout<class_WebSocketMultiplayerPeer_property_handshake_timeout>` | ``3.0`` |
  25. +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+
  26. | :ref:`int<class_int>` | :ref:`inbound_buffer_size<class_WebSocketMultiplayerPeer_property_inbound_buffer_size>` | ``65535`` |
  27. +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+
  28. | :ref:`int<class_int>` | :ref:`max_queued_packets<class_WebSocketMultiplayerPeer_property_max_queued_packets>` | ``2048`` |
  29. +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+
  30. | :ref:`int<class_int>` | :ref:`outbound_buffer_size<class_WebSocketMultiplayerPeer_property_outbound_buffer_size>` | ``65535`` |
  31. +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+
  32. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`supported_protocols<class_WebSocketMultiplayerPeer_property_supported_protocols>` | ``PackedStringArray()`` |
  33. +---------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------+
  34. .. rst-class:: classref-reftable-group
  35. Methods
  36. -------
  37. .. table::
  38. :widths: auto
  39. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_client<class_WebSocketMultiplayerPeer_method_create_client>` **(** :ref:`String<class_String>` url, :ref:`TLSOptions<class_TLSOptions>` tls_client_options=null **)** |
  41. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_server<class_WebSocketMultiplayerPeer_method_create_server>` **(** :ref:`int<class_int>` port, :ref:`String<class_String>` bind_address="*", :ref:`TLSOptions<class_TLSOptions>` tls_server_options=null **)** |
  43. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`WebSocketPeer<class_WebSocketPeer>` | :ref:`get_peer<class_WebSocketMultiplayerPeer_method_get_peer>` **(** :ref:`int<class_int>` peer_id **)** |const| |
  45. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`String<class_String>` | :ref:`get_peer_address<class_WebSocketMultiplayerPeer_method_get_peer_address>` **(** :ref:`int<class_int>` id **)** |const| |
  47. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`get_peer_port<class_WebSocketMultiplayerPeer_method_get_peer_port>` **(** :ref:`int<class_int>` id **)** |const| |
  49. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. .. rst-class:: classref-section-separator
  51. ----
  52. .. rst-class:: classref-descriptions-group
  53. Property Descriptions
  54. ---------------------
  55. .. _class_WebSocketMultiplayerPeer_property_handshake_headers:
  56. .. rst-class:: classref-property
  57. :ref:`PackedStringArray<class_PackedStringArray>` **handshake_headers** = ``PackedStringArray()``
  58. .. rst-class:: classref-property-setget
  59. - void **set_handshake_headers** **(** :ref:`PackedStringArray<class_PackedStringArray>` value **)**
  60. - :ref:`PackedStringArray<class_PackedStringArray>` **get_handshake_headers** **(** **)**
  61. The extra headers to use during handshake. See :ref:`WebSocketPeer.handshake_headers<class_WebSocketPeer_property_handshake_headers>` for more details.
  62. .. rst-class:: classref-item-separator
  63. ----
  64. .. _class_WebSocketMultiplayerPeer_property_handshake_timeout:
  65. .. rst-class:: classref-property
  66. :ref:`float<class_float>` **handshake_timeout** = ``3.0``
  67. .. rst-class:: classref-property-setget
  68. - void **set_handshake_timeout** **(** :ref:`float<class_float>` value **)**
  69. - :ref:`float<class_float>` **get_handshake_timeout** **(** **)**
  70. The maximum time each peer can stay in a connecting state before being dropped.
  71. .. rst-class:: classref-item-separator
  72. ----
  73. .. _class_WebSocketMultiplayerPeer_property_inbound_buffer_size:
  74. .. rst-class:: classref-property
  75. :ref:`int<class_int>` **inbound_buffer_size** = ``65535``
  76. .. rst-class:: classref-property-setget
  77. - void **set_inbound_buffer_size** **(** :ref:`int<class_int>` value **)**
  78. - :ref:`int<class_int>` **get_inbound_buffer_size** **(** **)**
  79. The inbound buffer size for connected peers. See :ref:`WebSocketPeer.inbound_buffer_size<class_WebSocketPeer_property_inbound_buffer_size>` for more details.
  80. .. rst-class:: classref-item-separator
  81. ----
  82. .. _class_WebSocketMultiplayerPeer_property_max_queued_packets:
  83. .. rst-class:: classref-property
  84. :ref:`int<class_int>` **max_queued_packets** = ``2048``
  85. .. rst-class:: classref-property-setget
  86. - void **set_max_queued_packets** **(** :ref:`int<class_int>` value **)**
  87. - :ref:`int<class_int>` **get_max_queued_packets** **(** **)**
  88. The maximum number of queued packets for connected peers. See :ref:`WebSocketPeer.max_queued_packets<class_WebSocketPeer_property_max_queued_packets>` for more details.
  89. .. rst-class:: classref-item-separator
  90. ----
  91. .. _class_WebSocketMultiplayerPeer_property_outbound_buffer_size:
  92. .. rst-class:: classref-property
  93. :ref:`int<class_int>` **outbound_buffer_size** = ``65535``
  94. .. rst-class:: classref-property-setget
  95. - void **set_outbound_buffer_size** **(** :ref:`int<class_int>` value **)**
  96. - :ref:`int<class_int>` **get_outbound_buffer_size** **(** **)**
  97. The outbound buffer size for connected peers. See :ref:`WebSocketPeer.outbound_buffer_size<class_WebSocketPeer_property_outbound_buffer_size>` for more details.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_WebSocketMultiplayerPeer_property_supported_protocols:
  101. .. rst-class:: classref-property
  102. :ref:`PackedStringArray<class_PackedStringArray>` **supported_protocols** = ``PackedStringArray()``
  103. .. rst-class:: classref-property-setget
  104. - void **set_supported_protocols** **(** :ref:`PackedStringArray<class_PackedStringArray>` value **)**
  105. - :ref:`PackedStringArray<class_PackedStringArray>` **get_supported_protocols** **(** **)**
  106. The supported WebSocket sub-protocols. See :ref:`WebSocketPeer.supported_protocols<class_WebSocketPeer_property_supported_protocols>` for more details.
  107. .. rst-class:: classref-section-separator
  108. ----
  109. .. rst-class:: classref-descriptions-group
  110. Method Descriptions
  111. -------------------
  112. .. _class_WebSocketMultiplayerPeer_method_create_client:
  113. .. rst-class:: classref-method
  114. :ref:`Error<enum_@GlobalScope_Error>` **create_client** **(** :ref:`String<class_String>` url, :ref:`TLSOptions<class_TLSOptions>` tls_client_options=null **)**
  115. 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 :ref:`TLSOptions.client<class_TLSOptions_method_client>` and :ref:`TLSOptions.client_unsafe<class_TLSOptions_method_client_unsafe>`.
  116. \ **Note:** It is recommended to specify the scheme part of the URL, i.e. the ``url`` should start with either ``ws://`` or ``wss://``.
  117. .. rst-class:: classref-item-separator
  118. ----
  119. .. _class_WebSocketMultiplayerPeer_method_create_server:
  120. .. rst-class:: classref-method
  121. :ref:`Error<enum_@GlobalScope_Error>` **create_server** **(** :ref:`int<class_int>` port, :ref:`String<class_String>` bind_address="*", :ref:`TLSOptions<class_TLSOptions>` tls_server_options=null **)**
  122. 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 :ref:`TLSOptions.server<class_TLSOptions_method_server>`.
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_WebSocketMultiplayerPeer_method_get_peer:
  126. .. rst-class:: classref-method
  127. :ref:`WebSocketPeer<class_WebSocketPeer>` **get_peer** **(** :ref:`int<class_int>` peer_id **)** |const|
  128. Returns the :ref:`WebSocketPeer<class_WebSocketPeer>` associated to the given ``peer_id``.
  129. .. rst-class:: classref-item-separator
  130. ----
  131. .. _class_WebSocketMultiplayerPeer_method_get_peer_address:
  132. .. rst-class:: classref-method
  133. :ref:`String<class_String>` **get_peer_address** **(** :ref:`int<class_int>` id **)** |const|
  134. Returns the IP address of the given peer.
  135. .. rst-class:: classref-item-separator
  136. ----
  137. .. _class_WebSocketMultiplayerPeer_method_get_peer_port:
  138. .. rst-class:: classref-method
  139. :ref:`int<class_int>` **get_peer_port** **(** :ref:`int<class_int>` id **)** |const|
  140. Returns the remote port of the given peer.
  141. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  142. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  143. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  144. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  145. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  146. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  147. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`