PacketPeer.xml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="PacketPeer" inherits="Reference" category="Core" version="3.1.2">
  3. <brief_description>
  4. Abstraction and base class for packet-based protocols.
  5. </brief_description>
  6. <description>
  7. PacketPeer is an abstraction and base class for packet-based protocols (such as UDP). It provides an API for sending and receiving packets both as raw data or variables. This makes it easy to transfer data over a protocol, without having to encode data as low level bytes or having to worry about network ordering.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="get_available_packet_count" qualifiers="const">
  13. <return type="int">
  14. </return>
  15. <description>
  16. Returns the number of packets currently available in the ring-buffer.
  17. </description>
  18. </method>
  19. <method name="get_packet">
  20. <return type="PoolByteArray">
  21. </return>
  22. <description>
  23. Get a raw packet.
  24. </description>
  25. </method>
  26. <method name="get_packet_error" qualifiers="const">
  27. <return type="int" enum="Error">
  28. </return>
  29. <description>
  30. Returns the error state of the last packet received (via [method get_packet] and [method get_var]).
  31. </description>
  32. </method>
  33. <method name="get_var">
  34. <return type="Variant">
  35. </return>
  36. <argument index="0" name="allow_objects" type="bool" default="false">
  37. </argument>
  38. <description>
  39. Get a Variant. When [code]allow_objects[/code] (or [member allow_object_decoding]) is [code]true[/code] decoding objects is allowed.
  40. [b]WARNING:[/b] Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution).
  41. </description>
  42. </method>
  43. <method name="put_packet">
  44. <return type="int" enum="Error">
  45. </return>
  46. <argument index="0" name="buffer" type="PoolByteArray">
  47. </argument>
  48. <description>
  49. Send a raw packet.
  50. </description>
  51. </method>
  52. <method name="put_var">
  53. <return type="int" enum="Error">
  54. </return>
  55. <argument index="0" name="var" type="Variant">
  56. </argument>
  57. <argument index="1" name="full_objects" type="bool" default="false">
  58. </argument>
  59. <description>
  60. Send a Variant as a packet. When [code]full_objects[/code] (or [member allow_object_decoding]) is [code]true[/code] encoding objects is allowed (and can potentially include code).
  61. </description>
  62. </method>
  63. </methods>
  64. <members>
  65. <member name="allow_object_decoding" type="bool" setter="set_allow_object_decoding" getter="is_object_decoding_allowed">
  66. Deprecated. Use [code]get_var[/code] and [code]put_var[/code] parameters instead.
  67. If [code]true[/code] the PacketPeer will allow encoding and decoding of object via [method get_var] and [method put_var].
  68. [b]WARNING:[/b] Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution).
  69. </member>
  70. </members>
  71. <constants>
  72. </constants>
  73. </class>