class_enetpacketpeer.rst 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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/enet/doc_classes/ENetPacketPeer.xml.
  6. .. _class_ENetPacketPeer:
  7. ENetPacketPeer
  8. ==============
  9. **Inherits:** :ref:`PacketPeer<class_PacketPeer>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A wrapper class for an `ENetPeer <http://enet.bespin.org/group__peer.html>`__.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A PacketPeer implementation representing a peer of an :ref:`ENetConnection<class_ENetConnection>`.
  15. This class cannot be instantiated directly but can be retrieved during :ref:`ENetConnection.service<class_ENetConnection_method_service>` or via :ref:`ENetConnection.get_peers<class_ENetConnection_method_get_peers>`.
  16. \ **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.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - `API documentation on the ENet website <http://enet.bespin.org/usergroup0.html>`__
  21. .. rst-class:: classref-reftable-group
  22. Methods
  23. -------
  24. .. table::
  25. :widths: auto
  26. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`get_channels<class_ENetPacketPeer_method_get_channels>`\ (\ ) |const| |
  28. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`get_packet_flags<class_ENetPacketPeer_method_get_packet_flags>`\ (\ ) |const| |
  30. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`String<class_String>` | :ref:`get_remote_address<class_ENetPacketPeer_method_get_remote_address>`\ (\ ) |const| |
  32. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`int<class_int>` | :ref:`get_remote_port<class_ENetPacketPeer_method_get_remote_port>`\ (\ ) |const| |
  34. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`PeerState<enum_ENetPacketPeer_PeerState>` | :ref:`get_state<class_ENetPacketPeer_method_get_state>`\ (\ ) |const| |
  36. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`float<class_float>` | :ref:`get_statistic<class_ENetPacketPeer_method_get_statistic>`\ (\ statistic\: :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>`\ ) |
  38. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`bool<class_bool>` | :ref:`is_active<class_ENetPacketPeer_method_is_active>`\ (\ ) |const| |
  40. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | |void| | :ref:`peer_disconnect<class_ENetPacketPeer_method_peer_disconnect>`\ (\ data\: :ref:`int<class_int>` = 0\ ) |
  42. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | |void| | :ref:`peer_disconnect_later<class_ENetPacketPeer_method_peer_disconnect_later>`\ (\ data\: :ref:`int<class_int>` = 0\ ) |
  44. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | |void| | :ref:`peer_disconnect_now<class_ENetPacketPeer_method_peer_disconnect_now>`\ (\ data\: :ref:`int<class_int>` = 0\ ) |
  46. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | |void| | :ref:`ping<class_ENetPacketPeer_method_ping>`\ (\ ) |
  48. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | |void| | :ref:`ping_interval<class_ENetPacketPeer_method_ping_interval>`\ (\ ping_interval\: :ref:`int<class_int>`\ ) |
  50. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | |void| | :ref:`reset<class_ENetPacketPeer_method_reset>`\ (\ ) |
  52. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`send<class_ENetPacketPeer_method_send>`\ (\ channel\: :ref:`int<class_int>`, packet\: :ref:`PackedByteArray<class_PackedByteArray>`, flags\: :ref:`int<class_int>`\ ) |
  54. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | |void| | :ref:`set_timeout<class_ENetPacketPeer_method_set_timeout>`\ (\ timeout\: :ref:`int<class_int>`, timeout_min\: :ref:`int<class_int>`, timeout_max\: :ref:`int<class_int>`\ ) |
  56. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | |void| | :ref:`throttle_configure<class_ENetPacketPeer_method_throttle_configure>`\ (\ interval\: :ref:`int<class_int>`, acceleration\: :ref:`int<class_int>`, deceleration\: :ref:`int<class_int>`\ ) |
  58. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. .. rst-class:: classref-section-separator
  60. ----
  61. .. rst-class:: classref-descriptions-group
  62. Enumerations
  63. ------------
  64. .. _enum_ENetPacketPeer_PeerState:
  65. .. rst-class:: classref-enumeration
  66. enum **PeerState**: :ref:`🔗<enum_ENetPacketPeer_PeerState>`
  67. .. _class_ENetPacketPeer_constant_STATE_DISCONNECTED:
  68. .. rst-class:: classref-enumeration-constant
  69. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **STATE_DISCONNECTED** = ``0``
  70. The peer is disconnected.
  71. .. _class_ENetPacketPeer_constant_STATE_CONNECTING:
  72. .. rst-class:: classref-enumeration-constant
  73. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **STATE_CONNECTING** = ``1``
  74. The peer is currently attempting to connect.
  75. .. _class_ENetPacketPeer_constant_STATE_ACKNOWLEDGING_CONNECT:
  76. .. rst-class:: classref-enumeration-constant
  77. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **STATE_ACKNOWLEDGING_CONNECT** = ``2``
  78. The peer has acknowledged the connection request.
  79. .. _class_ENetPacketPeer_constant_STATE_CONNECTION_PENDING:
  80. .. rst-class:: classref-enumeration-constant
  81. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **STATE_CONNECTION_PENDING** = ``3``
  82. The peer is currently connecting.
  83. .. _class_ENetPacketPeer_constant_STATE_CONNECTION_SUCCEEDED:
  84. .. rst-class:: classref-enumeration-constant
  85. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **STATE_CONNECTION_SUCCEEDED** = ``4``
  86. The peer has successfully connected, but is not ready to communicate with yet (:ref:`STATE_CONNECTED<class_ENetPacketPeer_constant_STATE_CONNECTED>`).
  87. .. _class_ENetPacketPeer_constant_STATE_CONNECTED:
  88. .. rst-class:: classref-enumeration-constant
  89. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **STATE_CONNECTED** = ``5``
  90. The peer is currently connected and ready to communicate with.
  91. .. _class_ENetPacketPeer_constant_STATE_DISCONNECT_LATER:
  92. .. rst-class:: classref-enumeration-constant
  93. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **STATE_DISCONNECT_LATER** = ``6``
  94. The peer is slated to disconnect after it has no more outgoing packets to send.
  95. .. _class_ENetPacketPeer_constant_STATE_DISCONNECTING:
  96. .. rst-class:: classref-enumeration-constant
  97. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **STATE_DISCONNECTING** = ``7``
  98. The peer is currently disconnecting.
  99. .. _class_ENetPacketPeer_constant_STATE_ACKNOWLEDGING_DISCONNECT:
  100. .. rst-class:: classref-enumeration-constant
  101. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **STATE_ACKNOWLEDGING_DISCONNECT** = ``8``
  102. The peer has acknowledged the disconnection request.
  103. .. _class_ENetPacketPeer_constant_STATE_ZOMBIE:
  104. .. rst-class:: classref-enumeration-constant
  105. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **STATE_ZOMBIE** = ``9``
  106. The peer has lost connection, but is not considered truly disconnected (as the peer didn't acknowledge the disconnection request).
  107. .. rst-class:: classref-item-separator
  108. ----
  109. .. _enum_ENetPacketPeer_PeerStatistic:
  110. .. rst-class:: classref-enumeration
  111. enum **PeerStatistic**: :ref:`🔗<enum_ENetPacketPeer_PeerStatistic>`
  112. .. _class_ENetPacketPeer_constant_PEER_PACKET_LOSS:
  113. .. rst-class:: classref-enumeration-constant
  114. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_PACKET_LOSS** = ``0``
  115. Mean packet loss of reliable packets as a ratio with respect to the :ref:`PACKET_LOSS_SCALE<class_ENetPacketPeer_constant_PACKET_LOSS_SCALE>`.
  116. .. _class_ENetPacketPeer_constant_PEER_PACKET_LOSS_VARIANCE:
  117. .. rst-class:: classref-enumeration-constant
  118. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_PACKET_LOSS_VARIANCE** = ``1``
  119. Packet loss variance.
  120. .. _class_ENetPacketPeer_constant_PEER_PACKET_LOSS_EPOCH:
  121. .. rst-class:: classref-enumeration-constant
  122. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_PACKET_LOSS_EPOCH** = ``2``
  123. The time at which packet loss statistics were last updated (in milliseconds since the connection started). The interval for packet loss statistics updates is 10 seconds, and at least one packet must have been sent since the last statistics update.
  124. .. _class_ENetPacketPeer_constant_PEER_ROUND_TRIP_TIME:
  125. .. rst-class:: classref-enumeration-constant
  126. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_ROUND_TRIP_TIME** = ``3``
  127. Mean packet round trip time for reliable packets.
  128. .. _class_ENetPacketPeer_constant_PEER_ROUND_TRIP_TIME_VARIANCE:
  129. .. rst-class:: classref-enumeration-constant
  130. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_ROUND_TRIP_TIME_VARIANCE** = ``4``
  131. Variance of the mean round trip time.
  132. .. _class_ENetPacketPeer_constant_PEER_LAST_ROUND_TRIP_TIME:
  133. .. rst-class:: classref-enumeration-constant
  134. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_LAST_ROUND_TRIP_TIME** = ``5``
  135. Last recorded round trip time for a reliable packet.
  136. .. _class_ENetPacketPeer_constant_PEER_LAST_ROUND_TRIP_TIME_VARIANCE:
  137. .. rst-class:: classref-enumeration-constant
  138. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_LAST_ROUND_TRIP_TIME_VARIANCE** = ``6``
  139. Variance of the last trip time recorded.
  140. .. _class_ENetPacketPeer_constant_PEER_PACKET_THROTTLE:
  141. .. rst-class:: classref-enumeration-constant
  142. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_PACKET_THROTTLE** = ``7``
  143. The peer's current throttle status.
  144. .. _class_ENetPacketPeer_constant_PEER_PACKET_THROTTLE_LIMIT:
  145. .. rst-class:: classref-enumeration-constant
  146. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_PACKET_THROTTLE_LIMIT** = ``8``
  147. The maximum number of unreliable packets that should not be dropped. This value is always greater than or equal to ``1``. The initial value is equal to :ref:`PACKET_THROTTLE_SCALE<class_ENetPacketPeer_constant_PACKET_THROTTLE_SCALE>`.
  148. .. _class_ENetPacketPeer_constant_PEER_PACKET_THROTTLE_COUNTER:
  149. .. rst-class:: classref-enumeration-constant
  150. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_PACKET_THROTTLE_COUNTER** = ``9``
  151. Internal value used to increment the packet throttle counter. The value is hardcoded to ``7`` and cannot be changed. You probably want to look at :ref:`PEER_PACKET_THROTTLE_ACCELERATION<class_ENetPacketPeer_constant_PEER_PACKET_THROTTLE_ACCELERATION>` instead.
  152. .. _class_ENetPacketPeer_constant_PEER_PACKET_THROTTLE_EPOCH:
  153. .. rst-class:: classref-enumeration-constant
  154. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_PACKET_THROTTLE_EPOCH** = ``10``
  155. The time at which throttle statistics were last updated (in milliseconds since the connection started). The interval for throttle statistics updates is :ref:`PEER_PACKET_THROTTLE_INTERVAL<class_ENetPacketPeer_constant_PEER_PACKET_THROTTLE_INTERVAL>`.
  156. .. _class_ENetPacketPeer_constant_PEER_PACKET_THROTTLE_ACCELERATION:
  157. .. rst-class:: classref-enumeration-constant
  158. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_PACKET_THROTTLE_ACCELERATION** = ``11``
  159. The throttle's acceleration factor. Higher values will make ENet adapt to fluctuating network conditions faster, causing unrelaible packets to be sent *more* often. The default value is ``2``.
  160. .. _class_ENetPacketPeer_constant_PEER_PACKET_THROTTLE_DECELERATION:
  161. .. rst-class:: classref-enumeration-constant
  162. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_PACKET_THROTTLE_DECELERATION** = ``12``
  163. The throttle's deceleration factor. Higher values will make ENet adapt to fluctuating network conditions faster, causing unrelaible packets to be sent *less* often. The default value is ``2``.
  164. .. _class_ENetPacketPeer_constant_PEER_PACKET_THROTTLE_INTERVAL:
  165. .. rst-class:: classref-enumeration-constant
  166. :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>` **PEER_PACKET_THROTTLE_INTERVAL** = ``13``
  167. The interval over which the lowest mean round trip time should be measured for use by the throttle mechanism (in milliseconds). The default value is ``5000``.
  168. .. rst-class:: classref-section-separator
  169. ----
  170. .. rst-class:: classref-descriptions-group
  171. Constants
  172. ---------
  173. .. _class_ENetPacketPeer_constant_PACKET_LOSS_SCALE:
  174. .. rst-class:: classref-constant
  175. **PACKET_LOSS_SCALE** = ``65536`` :ref:`🔗<class_ENetPacketPeer_constant_PACKET_LOSS_SCALE>`
  176. The reference scale for packet loss. See :ref:`get_statistic<class_ENetPacketPeer_method_get_statistic>` and :ref:`PEER_PACKET_LOSS<class_ENetPacketPeer_constant_PEER_PACKET_LOSS>`.
  177. .. _class_ENetPacketPeer_constant_PACKET_THROTTLE_SCALE:
  178. .. rst-class:: classref-constant
  179. **PACKET_THROTTLE_SCALE** = ``32`` :ref:`🔗<class_ENetPacketPeer_constant_PACKET_THROTTLE_SCALE>`
  180. The reference value for throttle configuration. The default value is ``32``. See :ref:`throttle_configure<class_ENetPacketPeer_method_throttle_configure>`.
  181. .. _class_ENetPacketPeer_constant_FLAG_RELIABLE:
  182. .. rst-class:: classref-constant
  183. **FLAG_RELIABLE** = ``1`` :ref:`🔗<class_ENetPacketPeer_constant_FLAG_RELIABLE>`
  184. Mark the packet to be sent as reliable.
  185. .. _class_ENetPacketPeer_constant_FLAG_UNSEQUENCED:
  186. .. rst-class:: classref-constant
  187. **FLAG_UNSEQUENCED** = ``2`` :ref:`🔗<class_ENetPacketPeer_constant_FLAG_UNSEQUENCED>`
  188. Mark the packet to be sent unsequenced (unreliable).
  189. .. _class_ENetPacketPeer_constant_FLAG_UNRELIABLE_FRAGMENT:
  190. .. rst-class:: classref-constant
  191. **FLAG_UNRELIABLE_FRAGMENT** = ``8`` :ref:`🔗<class_ENetPacketPeer_constant_FLAG_UNRELIABLE_FRAGMENT>`
  192. Mark the packet to be sent unreliable even if the packet is too big and needs fragmentation (increasing the chance of it being dropped).
  193. .. rst-class:: classref-section-separator
  194. ----
  195. .. rst-class:: classref-descriptions-group
  196. Method Descriptions
  197. -------------------
  198. .. _class_ENetPacketPeer_method_get_channels:
  199. .. rst-class:: classref-method
  200. :ref:`int<class_int>` **get_channels**\ (\ ) |const| :ref:`🔗<class_ENetPacketPeer_method_get_channels>`
  201. Returns the number of channels allocated for communication with peer.
  202. .. rst-class:: classref-item-separator
  203. ----
  204. .. _class_ENetPacketPeer_method_get_packet_flags:
  205. .. rst-class:: classref-method
  206. :ref:`int<class_int>` **get_packet_flags**\ (\ ) |const| :ref:`🔗<class_ENetPacketPeer_method_get_packet_flags>`
  207. Returns the ENet flags of the next packet in the received queue. See ``FLAG_*`` constants for available packet flags. Note that not all flags are replicated from the sending peer to the receiving peer.
  208. .. rst-class:: classref-item-separator
  209. ----
  210. .. _class_ENetPacketPeer_method_get_remote_address:
  211. .. rst-class:: classref-method
  212. :ref:`String<class_String>` **get_remote_address**\ (\ ) |const| :ref:`🔗<class_ENetPacketPeer_method_get_remote_address>`
  213. Returns the IP address of this peer.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_ENetPacketPeer_method_get_remote_port:
  217. .. rst-class:: classref-method
  218. :ref:`int<class_int>` **get_remote_port**\ (\ ) |const| :ref:`🔗<class_ENetPacketPeer_method_get_remote_port>`
  219. Returns the remote port of this peer.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_ENetPacketPeer_method_get_state:
  223. .. rst-class:: classref-method
  224. :ref:`PeerState<enum_ENetPacketPeer_PeerState>` **get_state**\ (\ ) |const| :ref:`🔗<class_ENetPacketPeer_method_get_state>`
  225. Returns the current peer state. See :ref:`PeerState<enum_ENetPacketPeer_PeerState>`.
  226. .. rst-class:: classref-item-separator
  227. ----
  228. .. _class_ENetPacketPeer_method_get_statistic:
  229. .. rst-class:: classref-method
  230. :ref:`float<class_float>` **get_statistic**\ (\ statistic\: :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>`\ ) :ref:`🔗<class_ENetPacketPeer_method_get_statistic>`
  231. Returns the requested ``statistic`` for this peer. See :ref:`PeerStatistic<enum_ENetPacketPeer_PeerStatistic>`.
  232. .. rst-class:: classref-item-separator
  233. ----
  234. .. _class_ENetPacketPeer_method_is_active:
  235. .. rst-class:: classref-method
  236. :ref:`bool<class_bool>` **is_active**\ (\ ) |const| :ref:`🔗<class_ENetPacketPeer_method_is_active>`
  237. Returns ``true`` if the peer is currently active (i.e. the associated :ref:`ENetConnection<class_ENetConnection>` is still valid).
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_ENetPacketPeer_method_peer_disconnect:
  241. .. rst-class:: classref-method
  242. |void| **peer_disconnect**\ (\ data\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_ENetPacketPeer_method_peer_disconnect>`
  243. Request a disconnection from a peer. An :ref:`ENetConnection.EVENT_DISCONNECT<class_ENetConnection_constant_EVENT_DISCONNECT>` will be generated during :ref:`ENetConnection.service<class_ENetConnection_method_service>` once the disconnection is complete.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_ENetPacketPeer_method_peer_disconnect_later:
  247. .. rst-class:: classref-method
  248. |void| **peer_disconnect_later**\ (\ data\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_ENetPacketPeer_method_peer_disconnect_later>`
  249. Request a disconnection from a peer, but only after all queued outgoing packets are sent. An :ref:`ENetConnection.EVENT_DISCONNECT<class_ENetConnection_constant_EVENT_DISCONNECT>` will be generated during :ref:`ENetConnection.service<class_ENetConnection_method_service>` once the disconnection is complete.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_ENetPacketPeer_method_peer_disconnect_now:
  253. .. rst-class:: classref-method
  254. |void| **peer_disconnect_now**\ (\ data\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_ENetPacketPeer_method_peer_disconnect_now>`
  255. Force an immediate disconnection from a peer. No :ref:`ENetConnection.EVENT_DISCONNECT<class_ENetConnection_constant_EVENT_DISCONNECT>` will be generated. The foreign peer is not guaranteed to receive the disconnect notification, and is reset immediately upon return from this function.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_ENetPacketPeer_method_ping:
  259. .. rst-class:: classref-method
  260. |void| **ping**\ (\ ) :ref:`🔗<class_ENetPacketPeer_method_ping>`
  261. Sends a ping request to a peer. ENet automatically pings all connected peers at regular intervals, however, this function may be called to ensure more frequent ping requests.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_ENetPacketPeer_method_ping_interval:
  265. .. rst-class:: classref-method
  266. |void| **ping_interval**\ (\ ping_interval\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ENetPacketPeer_method_ping_interval>`
  267. Sets the ``ping_interval`` in milliseconds at which pings will be sent to a peer. Pings are used both to monitor the liveness of the connection and also to dynamically adjust the throttle during periods of low traffic so that the throttle has reasonable responsiveness during traffic spikes. The default ping interval is ``500`` milliseconds.
  268. .. rst-class:: classref-item-separator
  269. ----
  270. .. _class_ENetPacketPeer_method_reset:
  271. .. rst-class:: classref-method
  272. |void| **reset**\ (\ ) :ref:`🔗<class_ENetPacketPeer_method_reset>`
  273. Forcefully disconnects a peer. The foreign host represented by the peer is not notified of the disconnection and will timeout on its connection to the local host.
  274. .. rst-class:: classref-item-separator
  275. ----
  276. .. _class_ENetPacketPeer_method_send:
  277. .. rst-class:: classref-method
  278. :ref:`Error<enum_@GlobalScope_Error>` **send**\ (\ channel\: :ref:`int<class_int>`, packet\: :ref:`PackedByteArray<class_PackedByteArray>`, flags\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ENetPacketPeer_method_send>`
  279. Queues a ``packet`` to be sent over the specified ``channel``. See ``FLAG_*`` constants for available packet flags.
  280. .. rst-class:: classref-item-separator
  281. ----
  282. .. _class_ENetPacketPeer_method_set_timeout:
  283. .. rst-class:: classref-method
  284. |void| **set_timeout**\ (\ timeout\: :ref:`int<class_int>`, timeout_min\: :ref:`int<class_int>`, timeout_max\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ENetPacketPeer_method_set_timeout>`
  285. 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.
  286. The ``timeout`` 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.
  287. .. rst-class:: classref-item-separator
  288. ----
  289. .. _class_ENetPacketPeer_method_throttle_configure:
  290. .. rst-class:: classref-method
  291. |void| **throttle_configure**\ (\ interval\: :ref:`int<class_int>`, acceleration\: :ref:`int<class_int>`, deceleration\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ENetPacketPeer_method_throttle_configure>`
  292. Configures throttle parameter for a peer.
  293. Unreliable packets are dropped by ENet in response to the varying conditions of the Internet connection to the peer. The throttle represents a probability that an unreliable packet should not be dropped and thus sent by ENet to the peer. By measuring fluctuations in round trip times of reliable packets over the specified ``interval``, ENet will either increase the probability by the amount specified in the ``acceleration`` parameter, or decrease it by the amount specified in the ``deceleration`` parameter (both are ratios to :ref:`PACKET_THROTTLE_SCALE<class_ENetPacketPeer_constant_PACKET_THROTTLE_SCALE>`).
  294. When the throttle has a value of :ref:`PACKET_THROTTLE_SCALE<class_ENetPacketPeer_constant_PACKET_THROTTLE_SCALE>`, no unreliable packets are dropped by ENet, and so 100% of all unreliable packets will be sent.
  295. When the throttle has a value of ``0``, all unreliable packets are dropped by ENet, and so 0% of all unreliable packets will be sent.
  296. Intermediate values for the throttle represent intermediate probabilities between 0% and 100% of unreliable packets being sent. The bandwidth limits of the local and foreign hosts are taken into account to determine a sensible limit for the throttle probability above which it should not raise even in the best of conditions.
  297. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  298. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  299. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  300. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  301. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  302. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  303. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  304. .. |void| replace:: :abbr:`void (No return value.)`