mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
122 lines
6.3 KiB
ReStructuredText
122 lines
6.3 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the PacketPeer.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_PacketPeer:
|
|
|
|
PacketPeer
|
|
==========
|
|
|
|
**Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
|
|
|
|
**Inherited By:** :ref:`NetworkedMultiplayerPeer<class_NetworkedMultiplayerPeer>`, :ref:`PacketPeerGDNative<class_PacketPeerGDNative>`, :ref:`PacketPeerStream<class_PacketPeerStream>`, :ref:`PacketPeerUDP<class_PacketPeerUDP>`, :ref:`WebSocketPeer<class_WebSocketPeer>`
|
|
|
|
**Category:** Core
|
|
|
|
Brief Description
|
|
-----------------
|
|
|
|
Abstraction and base class for packet-based protocols.
|
|
|
|
Properties
|
|
----------
|
|
|
|
+-------------------------+-------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`allow_object_decoding<class_PacketPeer_property_allow_object_decoding>` |
|
|
+-------------------------+-------------------------------------------------------------------------------+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+-------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_available_packet_count<class_PacketPeer_method_get_available_packet_count>` **(** **)** const |
|
|
+-------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`PoolByteArray<class_PoolByteArray>` | :ref:`get_packet<class_PacketPeer_method_get_packet>` **(** **)** |
|
|
+-------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`get_packet_error<class_PacketPeer_method_get_packet_error>` **(** **)** const |
|
|
+-------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Variant<class_Variant>` | :ref:`get_var<class_PacketPeer_method_get_var>` **(** :ref:`bool<class_bool>` allow_objects=false **)** |
|
|
+-------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`put_packet<class_PacketPeer_method_put_packet>` **(** :ref:`PoolByteArray<class_PoolByteArray>` buffer **)** |
|
|
+-------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`put_var<class_PacketPeer_method_put_var>` **(** :ref:`Variant<class_Variant>` var, :ref:`bool<class_bool>` full_objects=false **)** |
|
|
+-------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Description
|
|
-----------
|
|
|
|
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.
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_PacketPeer_property_allow_object_decoding:
|
|
|
|
- :ref:`bool<class_bool>` **allow_object_decoding**
|
|
|
|
+----------+----------------------------------+
|
|
| *Setter* | set_allow_object_decoding(value) |
|
|
+----------+----------------------------------+
|
|
| *Getter* | is_object_decoding_allowed() |
|
|
+----------+----------------------------------+
|
|
|
|
Deprecated. Use ``get_var`` and ``put_var`` parameters instead.
|
|
|
|
If ``true`` the PacketPeer will allow encoding and decoding of object via :ref:`get_var<class_PacketPeer_method_get_var>` and :ref:`put_var<class_PacketPeer_method_put_var>`.
|
|
|
|
**WARNING:** 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).
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_PacketPeer_method_get_available_packet_count:
|
|
|
|
- :ref:`int<class_int>` **get_available_packet_count** **(** **)** const
|
|
|
|
Returns the number of packets currently available in the ring-buffer.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeer_method_get_packet:
|
|
|
|
- :ref:`PoolByteArray<class_PoolByteArray>` **get_packet** **(** **)**
|
|
|
|
Get a raw packet.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeer_method_get_packet_error:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **get_packet_error** **(** **)** const
|
|
|
|
Returns the error state of the last packet received (via :ref:`get_packet<class_PacketPeer_method_get_packet>` and :ref:`get_var<class_PacketPeer_method_get_var>`).
|
|
|
|
----
|
|
|
|
.. _class_PacketPeer_method_get_var:
|
|
|
|
- :ref:`Variant<class_Variant>` **get_var** **(** :ref:`bool<class_bool>` allow_objects=false **)**
|
|
|
|
Get a Variant. When ``allow_objects`` (or :ref:`allow_object_decoding<class_PacketPeer_property_allow_object_decoding>`) is ``true`` decoding objects is allowed.
|
|
|
|
**WARNING:** 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).
|
|
|
|
----
|
|
|
|
.. _class_PacketPeer_method_put_packet:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **put_packet** **(** :ref:`PoolByteArray<class_PoolByteArray>` buffer **)**
|
|
|
|
Send a raw packet.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeer_method_put_var:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **put_var** **(** :ref:`Variant<class_Variant>` var, :ref:`bool<class_bool>` full_objects=false **)**
|
|
|
|
Send a Variant as a packet. When ``full_objects`` (or :ref:`allow_object_decoding<class_PacketPeer_property_allow_object_decoding>`) is ``true`` encoding objects is allowed (and can potentially include code).
|
|
|