class_networkedmultiplayerenet.rst 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/modules/enet/doc_classes/NetworkedMultiplayerENet.xml.
  6. .. _class_NetworkedMultiplayerENet:
  7. NetworkedMultiplayerENet
  8. ========================
  9. **Inherits:** :ref:`NetworkedMultiplayerPeer<class_NetworkedMultiplayerPeer>` **<** :ref:`PacketPeer<class_PacketPeer>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. PacketPeer implementation using the `ENet <http://enet.bespin.org/index.html>`__ library.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A PacketPeer implementation that should be passed to :ref:`SceneTree.network_peer<class_SceneTree_property_network_peer>` after being initialized as either a client or server. Events can then be handled by connecting to :ref:`SceneTree<class_SceneTree>` signals.
  15. ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol).
  16. \ **Note:** ENet only uses UDP, not TCP. When forwarding the server port to make your server accessible on the public Internet, you only need to forward the server port in UDP. You can use the :ref:`UPNP<class_UPNP>` class to try to forward the server port automatically when starting the server.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`../tutorials/networking/high_level_multiplayer`
  21. - `http://enet.bespin.org/usergroup0.html <http://enet.bespin.org/usergroup0.html>`__
  22. .. rst-class:: classref-reftable-group
  23. Properties
  24. ----------
  25. .. table::
  26. :widths: auto
  27. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  28. | :ref:`bool<class_bool>` | :ref:`always_ordered<class_NetworkedMultiplayerENet_property_always_ordered>` | ``false`` |
  29. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  30. | :ref:`int<class_int>` | :ref:`channel_count<class_NetworkedMultiplayerENet_property_channel_count>` | ``3`` |
  31. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  32. | :ref:`CompressionMode<enum_NetworkedMultiplayerENet_CompressionMode>` | :ref:`compression_mode<class_NetworkedMultiplayerENet_property_compression_mode>` | ``1`` |
  33. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  34. | :ref:`String<class_String>` | :ref:`dtls_hostname<class_NetworkedMultiplayerENet_property_dtls_hostname>` | ``""`` |
  35. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  36. | :ref:`bool<class_bool>` | :ref:`dtls_verify<class_NetworkedMultiplayerENet_property_dtls_verify>` | ``true`` |
  37. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  38. | :ref:`bool<class_bool>` | :ref:`server_relay<class_NetworkedMultiplayerENet_property_server_relay>` | ``true`` |
  39. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  40. | :ref:`int<class_int>` | :ref:`transfer_channel<class_NetworkedMultiplayerENet_property_transfer_channel>` | ``-1`` |
  41. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  42. | :ref:`bool<class_bool>` | :ref:`use_dtls<class_NetworkedMultiplayerENet_property_use_dtls>` | ``false`` |
  43. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  44. .. rst-class:: classref-reftable-group
  45. Methods
  46. -------
  47. .. table::
  48. :widths: auto
  49. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`close_connection<class_NetworkedMultiplayerENet_method_close_connection>` **(** :ref:`int<class_int>` wait_usec=100 **)** |
  51. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_client<class_NetworkedMultiplayerENet_method_create_client>` **(** :ref:`String<class_String>` address, :ref:`int<class_int>` port, :ref:`int<class_int>` in_bandwidth=0, :ref:`int<class_int>` out_bandwidth=0, :ref:`int<class_int>` client_port=0 **)** |
  53. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_server<class_NetworkedMultiplayerENet_method_create_server>` **(** :ref:`int<class_int>` port, :ref:`int<class_int>` max_clients=32, :ref:`int<class_int>` in_bandwidth=0, :ref:`int<class_int>` out_bandwidth=0 **)** |
  55. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`disconnect_peer<class_NetworkedMultiplayerENet_method_disconnect_peer>` **(** :ref:`int<class_int>` id, :ref:`bool<class_bool>` now=false **)** |
  57. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`int<class_int>` | :ref:`get_last_packet_channel<class_NetworkedMultiplayerENet_method_get_last_packet_channel>` **(** **)** |const| |
  59. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`int<class_int>` | :ref:`get_packet_channel<class_NetworkedMultiplayerENet_method_get_packet_channel>` **(** **)** |const| |
  61. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`String<class_String>` | :ref:`get_peer_address<class_NetworkedMultiplayerENet_method_get_peer_address>` **(** :ref:`int<class_int>` id **)** |const| |
  63. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`int<class_int>` | :ref:`get_peer_port<class_NetworkedMultiplayerENet_method_get_peer_port>` **(** :ref:`int<class_int>` id **)** |const| |
  65. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`set_bind_ip<class_NetworkedMultiplayerENet_method_set_bind_ip>` **(** :ref:`String<class_String>` ip **)** |
  67. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`set_dtls_certificate<class_NetworkedMultiplayerENet_method_set_dtls_certificate>` **(** :ref:`X509Certificate<class_X509Certificate>` certificate **)** |
  69. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`set_dtls_key<class_NetworkedMultiplayerENet_method_set_dtls_key>` **(** :ref:`CryptoKey<class_CryptoKey>` key **)** |
  71. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`set_peer_timeout<class_NetworkedMultiplayerENet_method_set_peer_timeout>` **(** :ref:`int<class_int>` id, :ref:`int<class_int>` timeout_limit, :ref:`int<class_int>` timeout_min, :ref:`int<class_int>` timeout_max **)** |
  73. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. .. rst-class:: classref-section-separator
  75. ----
  76. .. rst-class:: classref-descriptions-group
  77. Enumerations
  78. ------------
  79. .. _enum_NetworkedMultiplayerENet_CompressionMode:
  80. .. rst-class:: classref-enumeration
  81. enum **CompressionMode**:
  82. .. _class_NetworkedMultiplayerENet_constant_COMPRESS_NONE:
  83. .. rst-class:: classref-enumeration-constant
  84. :ref:`CompressionMode<enum_NetworkedMultiplayerENet_CompressionMode>` **COMPRESS_NONE** = ``0``
  85. No compression. This uses the most bandwidth, but has the upside of requiring the fewest CPU resources. This option may also be used to make network debugging using tools like Wireshark easier.
  86. .. _class_NetworkedMultiplayerENet_constant_COMPRESS_RANGE_CODER:
  87. .. rst-class:: classref-enumeration-constant
  88. :ref:`CompressionMode<enum_NetworkedMultiplayerENet_CompressionMode>` **COMPRESS_RANGE_CODER** = ``1``
  89. ENet's built-in range encoding. Works well on small packets, but is not the most efficient algorithm on packets larger than 4 KB.
  90. .. _class_NetworkedMultiplayerENet_constant_COMPRESS_FASTLZ:
  91. .. rst-class:: classref-enumeration-constant
  92. :ref:`CompressionMode<enum_NetworkedMultiplayerENet_CompressionMode>` **COMPRESS_FASTLZ** = ``2``
  93. `FastLZ <http://fastlz.org/>`__ compression. This option uses less CPU resources compared to :ref:`COMPRESS_ZLIB<class_NetworkedMultiplayerENet_constant_COMPRESS_ZLIB>`, at the expense of using more bandwidth.
  94. .. _class_NetworkedMultiplayerENet_constant_COMPRESS_ZLIB:
  95. .. rst-class:: classref-enumeration-constant
  96. :ref:`CompressionMode<enum_NetworkedMultiplayerENet_CompressionMode>` **COMPRESS_ZLIB** = ``3``
  97. `Zlib <https://www.zlib.net/>`__ compression. This option uses less bandwidth compared to :ref:`COMPRESS_FASTLZ<class_NetworkedMultiplayerENet_constant_COMPRESS_FASTLZ>`, at the expense of using more CPU resources. Note that this algorithm is not very efficient on packets smaller than 4 KB. Therefore, it's recommended to use other compression algorithms in most cases.
  98. .. _class_NetworkedMultiplayerENet_constant_COMPRESS_ZSTD:
  99. .. rst-class:: classref-enumeration-constant
  100. :ref:`CompressionMode<enum_NetworkedMultiplayerENet_CompressionMode>` **COMPRESS_ZSTD** = ``4``
  101. `Zstandard <https://facebook.github.io/zstd/>`__ compression.
  102. .. rst-class:: classref-section-separator
  103. ----
  104. .. rst-class:: classref-descriptions-group
  105. Property Descriptions
  106. ---------------------
  107. .. _class_NetworkedMultiplayerENet_property_always_ordered:
  108. .. rst-class:: classref-property
  109. :ref:`bool<class_bool>` **always_ordered** = ``false``
  110. .. rst-class:: classref-property-setget
  111. - void **set_always_ordered** **(** :ref:`bool<class_bool>` value **)**
  112. - :ref:`bool<class_bool>` **is_always_ordered** **(** **)**
  113. Enforce ordered packets when using :ref:`NetworkedMultiplayerPeer.TRANSFER_MODE_UNRELIABLE<class_NetworkedMultiplayerPeer_constant_TRANSFER_MODE_UNRELIABLE>` (thus behaving similarly to :ref:`NetworkedMultiplayerPeer.TRANSFER_MODE_UNRELIABLE_ORDERED<class_NetworkedMultiplayerPeer_constant_TRANSFER_MODE_UNRELIABLE_ORDERED>`). This is the only way to use ordering with the RPC system.
  114. .. rst-class:: classref-item-separator
  115. ----
  116. .. _class_NetworkedMultiplayerENet_property_channel_count:
  117. .. rst-class:: classref-property
  118. :ref:`int<class_int>` **channel_count** = ``3``
  119. .. rst-class:: classref-property-setget
  120. - void **set_channel_count** **(** :ref:`int<class_int>` value **)**
  121. - :ref:`int<class_int>` **get_channel_count** **(** **)**
  122. The number of channels to be used by ENet. Channels are used to separate different kinds of data. In reliable or ordered mode, for example, the packet delivery order is ensured on a per-channel basis. This is done to combat latency and reduces ordering restrictions on packets. The delivery status of a packet in one channel won't stall the delivery of other packets in another channel.
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_NetworkedMultiplayerENet_property_compression_mode:
  126. .. rst-class:: classref-property
  127. :ref:`CompressionMode<enum_NetworkedMultiplayerENet_CompressionMode>` **compression_mode** = ``1``
  128. .. rst-class:: classref-property-setget
  129. - void **set_compression_mode** **(** :ref:`CompressionMode<enum_NetworkedMultiplayerENet_CompressionMode>` value **)**
  130. - :ref:`CompressionMode<enum_NetworkedMultiplayerENet_CompressionMode>` **get_compression_mode** **(** **)**
  131. The compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all.
  132. \ **Note:** Most games' network design involve sending many small packets frequently (smaller than 4 KB each). If in doubt, it is recommended to keep the default compression algorithm as it works best on these small packets.
  133. \ **Note:** :ref:`compression_mode<class_NetworkedMultiplayerENet_property_compression_mode>` must be set to the same value on both the server and all its clients. Clients will fail to connect if the :ref:`compression_mode<class_NetworkedMultiplayerENet_property_compression_mode>` set on the client differs from the one set on the server. Prior to Godot 3.4, the default :ref:`compression_mode<class_NetworkedMultiplayerENet_property_compression_mode>` was :ref:`COMPRESS_NONE<class_NetworkedMultiplayerENet_constant_COMPRESS_NONE>`. Nonetheless, mixing engine versions between clients and server is not recommended and not officially supported.
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_NetworkedMultiplayerENet_property_dtls_hostname:
  137. .. rst-class:: classref-property
  138. :ref:`String<class_String>` **dtls_hostname** = ``""``
  139. .. rst-class:: classref-property-setget
  140. - void **set_dtls_hostname** **(** :ref:`String<class_String>` value **)**
  141. - :ref:`String<class_String>` **get_dtls_hostname** **(** **)**
  142. The hostname used for DTLS verification, to be compared against the "CN" value in the certificate provided by the server.
  143. When set to an empty string, the ``address`` parameter passed to :ref:`create_client<class_NetworkedMultiplayerENet_method_create_client>` is used instead.
  144. .. rst-class:: classref-item-separator
  145. ----
  146. .. _class_NetworkedMultiplayerENet_property_dtls_verify:
  147. .. rst-class:: classref-property
  148. :ref:`bool<class_bool>` **dtls_verify** = ``true``
  149. .. rst-class:: classref-property-setget
  150. - void **set_dtls_verify_enabled** **(** :ref:`bool<class_bool>` value **)**
  151. - :ref:`bool<class_bool>` **is_dtls_verify_enabled** **(** **)**
  152. Enable or disable certificate verification when :ref:`use_dtls<class_NetworkedMultiplayerENet_property_use_dtls>` is ``true``.
  153. .. rst-class:: classref-item-separator
  154. ----
  155. .. _class_NetworkedMultiplayerENet_property_server_relay:
  156. .. rst-class:: classref-property
  157. :ref:`bool<class_bool>` **server_relay** = ``true``
  158. .. rst-class:: classref-property-setget
  159. - void **set_server_relay_enabled** **(** :ref:`bool<class_bool>` value **)**
  160. - :ref:`bool<class_bool>` **is_server_relay_enabled** **(** **)**
  161. Enable or disable the server feature that notifies clients of other peers' connection/disconnection, and relays messages between them. When this option is ``false``, clients won't be automatically notified of other peers and won't be able to send them packets through the server.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_NetworkedMultiplayerENet_property_transfer_channel:
  165. .. rst-class:: classref-property
  166. :ref:`int<class_int>` **transfer_channel** = ``-1``
  167. .. rst-class:: classref-property-setget
  168. - void **set_transfer_channel** **(** :ref:`int<class_int>` value **)**
  169. - :ref:`int<class_int>` **get_transfer_channel** **(** **)**
  170. Set the default channel to be used to transfer data. By default, this value is ``-1`` which means that ENet will only use 2 channels: one for reliable packets, and one for unreliable packets. The channel ``0`` is reserved and cannot be used. Setting this member to any value between ``0`` and :ref:`channel_count<class_NetworkedMultiplayerENet_property_channel_count>` (excluded) will force ENet to use that channel for sending data. See :ref:`channel_count<class_NetworkedMultiplayerENet_property_channel_count>` for more information about ENet channels.
  171. .. rst-class:: classref-item-separator
  172. ----
  173. .. _class_NetworkedMultiplayerENet_property_use_dtls:
  174. .. rst-class:: classref-property
  175. :ref:`bool<class_bool>` **use_dtls** = ``false``
  176. .. rst-class:: classref-property-setget
  177. - void **set_dtls_enabled** **(** :ref:`bool<class_bool>` value **)**
  178. - :ref:`bool<class_bool>` **is_dtls_enabled** **(** **)**
  179. When enabled, the client or server created by this peer, will use :ref:`PacketPeerDTLS<class_PacketPeerDTLS>` instead of raw UDP sockets for communicating with the remote peer. This will make the communication encrypted with DTLS at the cost of higher resource usage and potentially larger packet size.
  180. \ **Note:** When creating a DTLS server, make sure you setup the key/certificate pair via :ref:`set_dtls_key<class_NetworkedMultiplayerENet_method_set_dtls_key>` and :ref:`set_dtls_certificate<class_NetworkedMultiplayerENet_method_set_dtls_certificate>`. For DTLS clients, have a look at the :ref:`dtls_verify<class_NetworkedMultiplayerENet_property_dtls_verify>` option, and configure the certificate accordingly via :ref:`set_dtls_certificate<class_NetworkedMultiplayerENet_method_set_dtls_certificate>`.
  181. .. rst-class:: classref-section-separator
  182. ----
  183. .. rst-class:: classref-descriptions-group
  184. Method Descriptions
  185. -------------------
  186. .. _class_NetworkedMultiplayerENet_method_close_connection:
  187. .. rst-class:: classref-method
  188. void **close_connection** **(** :ref:`int<class_int>` wait_usec=100 **)**
  189. Closes the connection. Ignored if no connection is currently established. If this is a server it tries to notify all clients before forcibly disconnecting them. If this is a client it simply closes the connection to the server.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_NetworkedMultiplayerENet_method_create_client:
  193. .. rst-class:: classref-method
  194. :ref:`Error<enum_@GlobalScope_Error>` **create_client** **(** :ref:`String<class_String>` address, :ref:`int<class_int>` port, :ref:`int<class_int>` in_bandwidth=0, :ref:`int<class_int>` out_bandwidth=0, :ref:`int<class_int>` client_port=0 **)**
  195. Create client that connects to a server at ``address`` using specified ``port``. The given address needs to be either a fully qualified domain name (e.g. ``"www.example.com"``) or an IP address in IPv4 or IPv6 format (e.g. ``"192.168.1.1"``). The ``port`` is the port the server is listening on. The ``in_bandwidth`` and ``out_bandwidth`` parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` if a client was created, :ref:`@GlobalScope.ERR_ALREADY_IN_USE<class_@GlobalScope_constant_ERR_ALREADY_IN_USE>` if this NetworkedMultiplayerENet instance already has an open connection (in which case you need to call :ref:`close_connection<class_NetworkedMultiplayerENet_method_close_connection>` first) or :ref:`@GlobalScope.ERR_CANT_CREATE<class_@GlobalScope_constant_ERR_CANT_CREATE>` if the client could not be created. If ``client_port`` is specified, the client will also listen to the given port; this is useful for some NAT traversal techniques.
  196. .. rst-class:: classref-item-separator
  197. ----
  198. .. _class_NetworkedMultiplayerENet_method_create_server:
  199. .. rst-class:: classref-method
  200. :ref:`Error<enum_@GlobalScope_Error>` **create_server** **(** :ref:`int<class_int>` port, :ref:`int<class_int>` max_clients=32, :ref:`int<class_int>` in_bandwidth=0, :ref:`int<class_int>` out_bandwidth=0 **)**
  201. Create server that listens to connections via ``port``. The port needs to be an available, unused port between 0 and 65535. Note that ports below 1024 are privileged and may require elevated permissions depending on the platform. To change the interface the server listens on, use :ref:`set_bind_ip<class_NetworkedMultiplayerENet_method_set_bind_ip>`. The default IP is the wildcard ``"*"``, which listens on all available interfaces. ``max_clients`` is the maximum number of clients that are allowed at once, any number up to 4095 may be used, although the achievable number of simultaneous clients may be far lower and depends on the application. For additional details on the bandwidth parameters, see :ref:`create_client<class_NetworkedMultiplayerENet_method_create_client>`. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` if a server was created, :ref:`@GlobalScope.ERR_ALREADY_IN_USE<class_@GlobalScope_constant_ERR_ALREADY_IN_USE>` if this NetworkedMultiplayerENet instance already has an open connection (in which case you need to call :ref:`close_connection<class_NetworkedMultiplayerENet_method_close_connection>` first) or :ref:`@GlobalScope.ERR_CANT_CREATE<class_@GlobalScope_constant_ERR_CANT_CREATE>` if the server could not be created.
  202. .. rst-class:: classref-item-separator
  203. ----
  204. .. _class_NetworkedMultiplayerENet_method_disconnect_peer:
  205. .. rst-class:: classref-method
  206. void **disconnect_peer** **(** :ref:`int<class_int>` id, :ref:`bool<class_bool>` now=false **)**
  207. Disconnect the given peer. If "now" is set to ``true``, the connection will be closed immediately without flushing queued messages.
  208. .. rst-class:: classref-item-separator
  209. ----
  210. .. _class_NetworkedMultiplayerENet_method_get_last_packet_channel:
  211. .. rst-class:: classref-method
  212. :ref:`int<class_int>` **get_last_packet_channel** **(** **)** |const|
  213. Returns the channel of the last packet fetched via :ref:`PacketPeer.get_packet<class_PacketPeer_method_get_packet>`.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_NetworkedMultiplayerENet_method_get_packet_channel:
  217. .. rst-class:: classref-method
  218. :ref:`int<class_int>` **get_packet_channel** **(** **)** |const|
  219. Returns the channel of the next packet that will be retrieved via :ref:`PacketPeer.get_packet<class_PacketPeer_method_get_packet>`.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_NetworkedMultiplayerENet_method_get_peer_address:
  223. .. rst-class:: classref-method
  224. :ref:`String<class_String>` **get_peer_address** **(** :ref:`int<class_int>` id **)** |const|
  225. Returns the IP address of the given peer.
  226. .. rst-class:: classref-item-separator
  227. ----
  228. .. _class_NetworkedMultiplayerENet_method_get_peer_port:
  229. .. rst-class:: classref-method
  230. :ref:`int<class_int>` **get_peer_port** **(** :ref:`int<class_int>` id **)** |const|
  231. Returns the remote port of the given peer.
  232. .. rst-class:: classref-item-separator
  233. ----
  234. .. _class_NetworkedMultiplayerENet_method_set_bind_ip:
  235. .. rst-class:: classref-method
  236. void **set_bind_ip** **(** :ref:`String<class_String>` ip **)**
  237. The IP used when creating a server. This is set to the wildcard ``"*"`` by default, which binds to all available interfaces. The given IP needs to be in IPv4 or IPv6 address format, for example: ``"192.168.1.1"``.
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_NetworkedMultiplayerENet_method_set_dtls_certificate:
  241. .. rst-class:: classref-method
  242. void **set_dtls_certificate** **(** :ref:`X509Certificate<class_X509Certificate>` certificate **)**
  243. Configure the :ref:`X509Certificate<class_X509Certificate>` to use when :ref:`use_dtls<class_NetworkedMultiplayerENet_property_use_dtls>` is ``true``. For servers, you must also setup the :ref:`CryptoKey<class_CryptoKey>` via :ref:`set_dtls_key<class_NetworkedMultiplayerENet_method_set_dtls_key>`.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_NetworkedMultiplayerENet_method_set_dtls_key:
  247. .. rst-class:: classref-method
  248. void **set_dtls_key** **(** :ref:`CryptoKey<class_CryptoKey>` key **)**
  249. Configure the :ref:`CryptoKey<class_CryptoKey>` to use when :ref:`use_dtls<class_NetworkedMultiplayerENet_property_use_dtls>` is ``true``. Remember to also call :ref:`set_dtls_certificate<class_NetworkedMultiplayerENet_method_set_dtls_certificate>` to setup your :ref:`X509Certificate<class_X509Certificate>`.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_NetworkedMultiplayerENet_method_set_peer_timeout:
  253. .. rst-class:: classref-method
  254. void **set_peer_timeout** **(** :ref:`int<class_int>` id, :ref:`int<class_int>` timeout_limit, :ref:`int<class_int>` timeout_min, :ref:`int<class_int>` timeout_max **)**
  255. Sets the timeout parameters for a peer. The timeout parameters control how and when a peer will timeout from a failure to acknowledge reliable traffic. Timeout values are expressed in milliseconds.
  256. The ``timeout_limit`` is a factor that, multiplied by a value based on the average round trip time, will determine the timeout limit for a reliable packet. When that limit is reached, the timeout will be doubled, and the peer will be disconnected if that limit has reached ``timeout_min``. The ``timeout_max`` parameter, on the other hand, defines a fixed timeout for which any packet must be acknowledged or the peer will be dropped.
  257. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  258. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  259. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  260. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`