class_websocketmultiplayerpeer.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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>` | ``4096`` |
  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>`\ (\ url\: :ref:`String<class_String>`, tls_client_options\: :ref:`TLSOptions<class_TLSOptions>` = null\ ) |
  41. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_server<class_WebSocketMultiplayerPeer_method_create_server>`\ (\ port\: :ref:`int<class_int>`, bind_address\: :ref:`String<class_String>` = "*", tls_server_options\: :ref:`TLSOptions<class_TLSOptions>` = null\ ) |
  43. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`WebSocketPeer<class_WebSocketPeer>` | :ref:`get_peer<class_WebSocketMultiplayerPeer_method_get_peer>`\ (\ peer_id\: :ref:`int<class_int>`\ ) |const| |
  45. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`String<class_String>` | :ref:`get_peer_address<class_WebSocketMultiplayerPeer_method_get_peer_address>`\ (\ id\: :ref:`int<class_int>`\ ) |const| |
  47. +-------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`get_peer_port<class_WebSocketMultiplayerPeer_method_get_peer_port>`\ (\ id\: :ref:`int<class_int>`\ ) |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()`` :ref:`🔗<class_WebSocketMultiplayerPeer_property_handshake_headers>`
  58. .. rst-class:: classref-property-setget
  59. - |void| **set_handshake_headers**\ (\ value\: :ref:`PackedStringArray<class_PackedStringArray>`\ )
  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. **Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedStringArray<class_PackedStringArray>` for more details.
  63. .. rst-class:: classref-item-separator
  64. ----
  65. .. _class_WebSocketMultiplayerPeer_property_handshake_timeout:
  66. .. rst-class:: classref-property
  67. :ref:`float<class_float>` **handshake_timeout** = ``3.0`` :ref:`🔗<class_WebSocketMultiplayerPeer_property_handshake_timeout>`
  68. .. rst-class:: classref-property-setget
  69. - |void| **set_handshake_timeout**\ (\ value\: :ref:`float<class_float>`\ )
  70. - :ref:`float<class_float>` **get_handshake_timeout**\ (\ )
  71. The maximum time each peer can stay in a connecting state before being dropped.
  72. .. rst-class:: classref-item-separator
  73. ----
  74. .. _class_WebSocketMultiplayerPeer_property_inbound_buffer_size:
  75. .. rst-class:: classref-property
  76. :ref:`int<class_int>` **inbound_buffer_size** = ``65535`` :ref:`🔗<class_WebSocketMultiplayerPeer_property_inbound_buffer_size>`
  77. .. rst-class:: classref-property-setget
  78. - |void| **set_inbound_buffer_size**\ (\ value\: :ref:`int<class_int>`\ )
  79. - :ref:`int<class_int>` **get_inbound_buffer_size**\ (\ )
  80. The inbound buffer size for connected peers. See :ref:`WebSocketPeer.inbound_buffer_size<class_WebSocketPeer_property_inbound_buffer_size>` for more details.
  81. .. rst-class:: classref-item-separator
  82. ----
  83. .. _class_WebSocketMultiplayerPeer_property_max_queued_packets:
  84. .. rst-class:: classref-property
  85. :ref:`int<class_int>` **max_queued_packets** = ``4096`` :ref:`🔗<class_WebSocketMultiplayerPeer_property_max_queued_packets>`
  86. .. rst-class:: classref-property-setget
  87. - |void| **set_max_queued_packets**\ (\ value\: :ref:`int<class_int>`\ )
  88. - :ref:`int<class_int>` **get_max_queued_packets**\ (\ )
  89. The maximum number of queued packets for connected peers. See :ref:`WebSocketPeer.max_queued_packets<class_WebSocketPeer_property_max_queued_packets>` for more details.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_WebSocketMultiplayerPeer_property_outbound_buffer_size:
  93. .. rst-class:: classref-property
  94. :ref:`int<class_int>` **outbound_buffer_size** = ``65535`` :ref:`🔗<class_WebSocketMultiplayerPeer_property_outbound_buffer_size>`
  95. .. rst-class:: classref-property-setget
  96. - |void| **set_outbound_buffer_size**\ (\ value\: :ref:`int<class_int>`\ )
  97. - :ref:`int<class_int>` **get_outbound_buffer_size**\ (\ )
  98. The outbound buffer size for connected peers. See :ref:`WebSocketPeer.outbound_buffer_size<class_WebSocketPeer_property_outbound_buffer_size>` for more details.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_WebSocketMultiplayerPeer_property_supported_protocols:
  102. .. rst-class:: classref-property
  103. :ref:`PackedStringArray<class_PackedStringArray>` **supported_protocols** = ``PackedStringArray()`` :ref:`🔗<class_WebSocketMultiplayerPeer_property_supported_protocols>`
  104. .. rst-class:: classref-property-setget
  105. - |void| **set_supported_protocols**\ (\ value\: :ref:`PackedStringArray<class_PackedStringArray>`\ )
  106. - :ref:`PackedStringArray<class_PackedStringArray>` **get_supported_protocols**\ (\ )
  107. The supported WebSocket sub-protocols. See :ref:`WebSocketPeer.supported_protocols<class_WebSocketPeer_property_supported_protocols>` for more details.
  108. **Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedStringArray<class_PackedStringArray>` for more details.
  109. .. rst-class:: classref-section-separator
  110. ----
  111. .. rst-class:: classref-descriptions-group
  112. Method Descriptions
  113. -------------------
  114. .. _class_WebSocketMultiplayerPeer_method_create_client:
  115. .. rst-class:: classref-method
  116. :ref:`Error<enum_@GlobalScope_Error>` **create_client**\ (\ url\: :ref:`String<class_String>`, tls_client_options\: :ref:`TLSOptions<class_TLSOptions>` = null\ ) :ref:`🔗<class_WebSocketMultiplayerPeer_method_create_client>`
  117. 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>`.
  118. \ **Note:** It is recommended to specify the scheme part of the URL, i.e. the ``url`` should start with either ``ws://`` or ``wss://``.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_WebSocketMultiplayerPeer_method_create_server:
  122. .. rst-class:: classref-method
  123. :ref:`Error<enum_@GlobalScope_Error>` **create_server**\ (\ port\: :ref:`int<class_int>`, bind_address\: :ref:`String<class_String>` = "*", tls_server_options\: :ref:`TLSOptions<class_TLSOptions>` = null\ ) :ref:`🔗<class_WebSocketMultiplayerPeer_method_create_server>`
  124. 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>`.
  125. .. rst-class:: classref-item-separator
  126. ----
  127. .. _class_WebSocketMultiplayerPeer_method_get_peer:
  128. .. rst-class:: classref-method
  129. :ref:`WebSocketPeer<class_WebSocketPeer>` **get_peer**\ (\ peer_id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_WebSocketMultiplayerPeer_method_get_peer>`
  130. Returns the :ref:`WebSocketPeer<class_WebSocketPeer>` associated to the given ``peer_id``.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_WebSocketMultiplayerPeer_method_get_peer_address:
  134. .. rst-class:: classref-method
  135. :ref:`String<class_String>` **get_peer_address**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_WebSocketMultiplayerPeer_method_get_peer_address>`
  136. Returns the IP address of the given peer.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. _class_WebSocketMultiplayerPeer_method_get_peer_port:
  140. .. rst-class:: classref-method
  141. :ref:`int<class_int>` **get_peer_port**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_WebSocketMultiplayerPeer_method_get_peer_port>`
  142. Returns the remote port of the given peer.
  143. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  144. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  145. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  146. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  147. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  148. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  149. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  150. .. |void| replace:: :abbr:`void (No return value.)`