ENetPacketPeer.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="ENetPacketPeer" inherits="PacketPeer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
  3. <brief_description>
  4. A wrapper class for an [url=http://enet.bespin.org/group__peer.html]ENetPeer[/url].
  5. </brief_description>
  6. <description>
  7. A PacketPeer implementation representing a peer of an [ENetConnection].
  8. This class cannot be instantiated directly but can be retrieved during [method ENetConnection.service] or via [method ENetConnection.get_peers].
  9. [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] 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.
  10. </description>
  11. <tutorials>
  12. <link title="API documentation on the ENet website">http://enet.bespin.org/usergroup0.html</link>
  13. </tutorials>
  14. <methods>
  15. <method name="get_channels" qualifiers="const">
  16. <return type="int" />
  17. <description>
  18. Returns the number of channels allocated for communication with peer.
  19. </description>
  20. </method>
  21. <method name="get_packet_flags" qualifiers="const">
  22. <return type="int" />
  23. <description>
  24. Returns the ENet flags of the next packet in the received queue. See [code]FLAG_*[/code] constants for available packet flags. Note that not all flags are replicated from the sending peer to the receiving peer.
  25. </description>
  26. </method>
  27. <method name="get_remote_address" qualifiers="const">
  28. <return type="String" />
  29. <description>
  30. Returns the IP address of this peer.
  31. </description>
  32. </method>
  33. <method name="get_remote_port" qualifiers="const">
  34. <return type="int" />
  35. <description>
  36. Returns the remote port of this peer.
  37. </description>
  38. </method>
  39. <method name="get_state" qualifiers="const">
  40. <return type="int" enum="ENetPacketPeer.PeerState" />
  41. <description>
  42. Returns the current peer state. See [enum PeerState].
  43. </description>
  44. </method>
  45. <method name="get_statistic">
  46. <return type="float" />
  47. <param index="0" name="statistic" type="int" enum="ENetPacketPeer.PeerStatistic" />
  48. <description>
  49. Returns the requested [param statistic] for this peer. See [enum PeerStatistic].
  50. </description>
  51. </method>
  52. <method name="is_active" qualifiers="const">
  53. <return type="bool" />
  54. <description>
  55. Returns [code]true[/code] if the peer is currently active (i.e. the associated [ENetConnection] is still valid).
  56. </description>
  57. </method>
  58. <method name="peer_disconnect">
  59. <return type="void" />
  60. <param index="0" name="data" type="int" default="0" />
  61. <description>
  62. Request a disconnection from a peer. An [constant ENetConnection.EVENT_DISCONNECT] will be generated during [method ENetConnection.service] once the disconnection is complete.
  63. </description>
  64. </method>
  65. <method name="peer_disconnect_later">
  66. <return type="void" />
  67. <param index="0" name="data" type="int" default="0" />
  68. <description>
  69. Request a disconnection from a peer, but only after all queued outgoing packets are sent. An [constant ENetConnection.EVENT_DISCONNECT] will be generated during [method ENetConnection.service] once the disconnection is complete.
  70. </description>
  71. </method>
  72. <method name="peer_disconnect_now">
  73. <return type="void" />
  74. <param index="0" name="data" type="int" default="0" />
  75. <description>
  76. Force an immediate disconnection from a peer. No [constant ENetConnection.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.
  77. </description>
  78. </method>
  79. <method name="ping">
  80. <return type="void" />
  81. <description>
  82. 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.
  83. </description>
  84. </method>
  85. <method name="ping_interval">
  86. <return type="void" />
  87. <param index="0" name="ping_interval" type="int" />
  88. <description>
  89. Sets the [param 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 [code]500[/code] milliseconds.
  90. </description>
  91. </method>
  92. <method name="reset">
  93. <return type="void" />
  94. <description>
  95. 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.
  96. </description>
  97. </method>
  98. <method name="send">
  99. <return type="int" enum="Error" />
  100. <param index="0" name="channel" type="int" />
  101. <param index="1" name="packet" type="PackedByteArray" />
  102. <param index="2" name="flags" type="int" />
  103. <description>
  104. Queues a [param packet] to be sent over the specified [param channel]. See [code]FLAG_*[/code] constants for available packet flags.
  105. </description>
  106. </method>
  107. <method name="set_timeout">
  108. <return type="void" />
  109. <param index="0" name="timeout" type="int" />
  110. <param index="1" name="timeout_min" type="int" />
  111. <param index="2" name="timeout_max" type="int" />
  112. <description>
  113. 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.
  114. The [param 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 [param timeout_min]. The [param timeout_max] parameter, on the other hand, defines a fixed timeout for which any packet must be acknowledged or the peer will be dropped.
  115. </description>
  116. </method>
  117. <method name="throttle_configure">
  118. <return type="void" />
  119. <param index="0" name="interval" type="int" />
  120. <param index="1" name="acceleration" type="int" />
  121. <param index="2" name="deceleration" type="int" />
  122. <description>
  123. Configures throttle parameter for a peer.
  124. 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 [param interval], ENet will either increase the probability by the amount specified in the [param acceleration] parameter, or decrease it by the amount specified in the [param deceleration] parameter (both are ratios to [constant PACKET_THROTTLE_SCALE]).
  125. When the throttle has a value of [constant PACKET_THROTTLE_SCALE], no unreliable packets are dropped by ENet, and so 100% of all unreliable packets will be sent.
  126. When the throttle has a value of [code]0[/code], all unreliable packets are dropped by ENet, and so 0% of all unreliable packets will be sent.
  127. 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.
  128. </description>
  129. </method>
  130. </methods>
  131. <constants>
  132. <constant name="STATE_DISCONNECTED" value="0" enum="PeerState">
  133. The peer is disconnected.
  134. </constant>
  135. <constant name="STATE_CONNECTING" value="1" enum="PeerState">
  136. The peer is currently attempting to connect.
  137. </constant>
  138. <constant name="STATE_ACKNOWLEDGING_CONNECT" value="2" enum="PeerState">
  139. The peer has acknowledged the connection request.
  140. </constant>
  141. <constant name="STATE_CONNECTION_PENDING" value="3" enum="PeerState">
  142. The peer is currently connecting.
  143. </constant>
  144. <constant name="STATE_CONNECTION_SUCCEEDED" value="4" enum="PeerState">
  145. The peer has successfully connected, but is not ready to communicate with yet ([constant STATE_CONNECTED]).
  146. </constant>
  147. <constant name="STATE_CONNECTED" value="5" enum="PeerState">
  148. The peer is currently connected and ready to communicate with.
  149. </constant>
  150. <constant name="STATE_DISCONNECT_LATER" value="6" enum="PeerState">
  151. The peer is slated to disconnect after it has no more outgoing packets to send.
  152. </constant>
  153. <constant name="STATE_DISCONNECTING" value="7" enum="PeerState">
  154. The peer is currently disconnecting.
  155. </constant>
  156. <constant name="STATE_ACKNOWLEDGING_DISCONNECT" value="8" enum="PeerState">
  157. The peer has acknowledged the disconnection request.
  158. </constant>
  159. <constant name="STATE_ZOMBIE" value="9" enum="PeerState">
  160. The peer has lost connection, but is not considered truly disconnected (as the peer didn't acknowledge the disconnection request).
  161. </constant>
  162. <constant name="PEER_PACKET_LOSS" value="0" enum="PeerStatistic">
  163. Mean packet loss of reliable packets as a ratio with respect to the [constant PACKET_LOSS_SCALE].
  164. </constant>
  165. <constant name="PEER_PACKET_LOSS_VARIANCE" value="1" enum="PeerStatistic">
  166. Packet loss variance.
  167. </constant>
  168. <constant name="PEER_PACKET_LOSS_EPOCH" value="2" enum="PeerStatistic">
  169. 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.
  170. </constant>
  171. <constant name="PEER_ROUND_TRIP_TIME" value="3" enum="PeerStatistic">
  172. Mean packet round trip time for reliable packets.
  173. </constant>
  174. <constant name="PEER_ROUND_TRIP_TIME_VARIANCE" value="4" enum="PeerStatistic">
  175. Variance of the mean round trip time.
  176. </constant>
  177. <constant name="PEER_LAST_ROUND_TRIP_TIME" value="5" enum="PeerStatistic">
  178. Last recorded round trip time for a reliable packet.
  179. </constant>
  180. <constant name="PEER_LAST_ROUND_TRIP_TIME_VARIANCE" value="6" enum="PeerStatistic">
  181. Variance of the last trip time recorded.
  182. </constant>
  183. <constant name="PEER_PACKET_THROTTLE" value="7" enum="PeerStatistic">
  184. The peer's current throttle status.
  185. </constant>
  186. <constant name="PEER_PACKET_THROTTLE_LIMIT" value="8" enum="PeerStatistic">
  187. The maximum number of unreliable packets that should not be dropped. This value is always greater than or equal to [code]1[/code]. The initial value is equal to [constant PACKET_THROTTLE_SCALE].
  188. </constant>
  189. <constant name="PEER_PACKET_THROTTLE_COUNTER" value="9" enum="PeerStatistic">
  190. Internal value used to increment the packet throttle counter. The value is hardcoded to [code]7[/code] and cannot be changed. You probably want to look at [constant PEER_PACKET_THROTTLE_ACCELERATION] instead.
  191. </constant>
  192. <constant name="PEER_PACKET_THROTTLE_EPOCH" value="10" enum="PeerStatistic">
  193. The time at which throttle statistics were last updated (in milliseconds since the connection started). The interval for throttle statistics updates is [constant PEER_PACKET_THROTTLE_INTERVAL].
  194. </constant>
  195. <constant name="PEER_PACKET_THROTTLE_ACCELERATION" value="11" enum="PeerStatistic">
  196. The throttle's acceleration factor. Higher values will make ENet adapt to fluctuating network conditions faster, causing unrelaible packets to be sent [i]more[/i] often. The default value is [code]2[/code].
  197. </constant>
  198. <constant name="PEER_PACKET_THROTTLE_DECELERATION" value="12" enum="PeerStatistic">
  199. The throttle's deceleration factor. Higher values will make ENet adapt to fluctuating network conditions faster, causing unrelaible packets to be sent [i]less[/i] often. The default value is [code]2[/code].
  200. </constant>
  201. <constant name="PEER_PACKET_THROTTLE_INTERVAL" value="13" enum="PeerStatistic">
  202. 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 [code]5000[/code].
  203. </constant>
  204. <constant name="PACKET_LOSS_SCALE" value="65536">
  205. The reference scale for packet loss. See [method get_statistic] and [constant PEER_PACKET_LOSS].
  206. </constant>
  207. <constant name="PACKET_THROTTLE_SCALE" value="32">
  208. The reference value for throttle configuration. The default value is [code]32[/code]. See [method throttle_configure].
  209. </constant>
  210. <constant name="FLAG_RELIABLE" value="1">
  211. Mark the packet to be sent as reliable.
  212. </constant>
  213. <constant name="FLAG_UNSEQUENCED" value="2">
  214. Mark the packet to be sent unsequenced (unreliable).
  215. </constant>
  216. <constant name="FLAG_UNRELIABLE_FRAGMENT" value="8">
  217. Mark the packet to be sent unreliable even if the packet is too big and needs fragmentation (increasing the chance of it being dropped).
  218. </constant>
  219. </constants>
  220. </class>