class_packetpeer.rst 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_PacketPeer:
  4. PacketPeer
  5. ==========
  6. **Inherits:** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  7. **Inherited By:** :ref:`PacketPeerStream<class_packetpeerstream>`, :ref:`PacketPeerUDP<class_packetpeerudp>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Abstraction and base class for packet-based protocols.
  12. Member Functions
  13. ----------------
  14. +----------------------------------+-----------------------------------------------------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`get_available_packet_count<class_PacketPeer_get_available_packet_count>` **(** **)** const |
  16. +----------------------------------+-----------------------------------------------------------------------------------------------------+
  17. | :ref:`RawArray<class_rawarray>` | :ref:`get_packet<class_PacketPeer_get_packet>` **(** **)** const |
  18. +----------------------------------+-----------------------------------------------------------------------------------------------------+
  19. | Error | :ref:`get_packet_error<class_PacketPeer_get_packet_error>` **(** **)** const |
  20. +----------------------------------+-----------------------------------------------------------------------------------------------------+
  21. | :ref:`Variant<class_variant>` | :ref:`get_var<class_PacketPeer_get_var>` **(** **)** const |
  22. +----------------------------------+-----------------------------------------------------------------------------------------------------+
  23. | Error | :ref:`put_packet<class_PacketPeer_put_packet>` **(** :ref:`RawArray<class_rawarray>` buffer **)** |
  24. +----------------------------------+-----------------------------------------------------------------------------------------------------+
  25. | :ref:`int<class_int>` | :ref:`put_var<class_PacketPeer_put_var>` **(** :ref:`Variant<class_variant>` var **)** |
  26. +----------------------------------+-----------------------------------------------------------------------------------------------------+
  27. Description
  28. -----------
  29. 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.
  30. Member Function Description
  31. ---------------------------
  32. .. _class_PacketPeer_get_available_packet_count:
  33. - :ref:`int<class_int>` **get_available_packet_count** **(** **)** const
  34. Return the number of packets currently available in the ring-buffer.
  35. .. _class_PacketPeer_get_packet:
  36. - :ref:`RawArray<class_rawarray>` **get_packet** **(** **)** const
  37. Get a raw packet.
  38. .. _class_PacketPeer_get_packet_error:
  39. - Error **get_packet_error** **(** **)** const
  40. Return the error state of the last packet received (via :ref:`get_packet<class_PacketPeer_get_packet>` and :ref:`get_var<class_PacketPeer_get_var>`).
  41. .. _class_PacketPeer_get_var:
  42. - :ref:`Variant<class_variant>` **get_var** **(** **)** const
  43. Get a Variant.
  44. .. _class_PacketPeer_put_packet:
  45. - Error **put_packet** **(** :ref:`RawArray<class_rawarray>` buffer **)**
  46. Send a raw packet.
  47. .. _class_PacketPeer_put_var:
  48. - :ref:`int<class_int>` **put_var** **(** :ref:`Variant<class_variant>` var **)**
  49. Send a Variant as a packet.