mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-04 10:09:56 +03:00
Currently including `zh_CN` and `es` which both have very high completion ratios. Others will be added once they reach a significant percentage too. These RST files will be used by godot-docs in place of its `classes` folder after we sync with https://github.com/godotengine/godot-docs/pull/5458. The update workflow is manual for now (example for `zh_CN`): - Build `godotengine/godot` in the branch we currently track (now `3.x`) - Run `godot --doctool -l zh_CN` - Run `cd doc && make rst LANGARG=zh_CN` - Copy `doc/_build/rst/*` to `classes/zh_CN/` here - Make sure to have `classes/zh_CN/index.rst` copied from `docs/classes`
142 lines
8.4 KiB
ReStructuredText
142 lines
8.4 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/make_rst.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:`PacketPeerDTLS<class_PacketPeerDTLS>`, :ref:`PacketPeerGDNative<class_PacketPeerGDNative>`, :ref:`PacketPeerStream<class_PacketPeerStream>`, :ref:`PacketPeerUDP<class_PacketPeerUDP>`, :ref:`WebRTCDataChannel<class_WebRTCDataChannel>`, :ref:`WebSocketPeer<class_WebSocketPeer>`
|
|
|
|
Abstracción y clase base para protocolos basados en paquetes.
|
|
|
|
Descripción
|
|
----------------------
|
|
|
|
PacketPeer es una clase de abstracción y base para protocolos basados en paquetes (como UDP). Proporciona una API para el envío y la recepción de paquetes tanto como datos en bruto o variables. Esto facilita la transferencia de datos a través de un protocolo, sin tener que codificar los datos como bytes de bajo nivel o tener que preocuparse por el ordenamiento de la red.
|
|
|
|
Propiedades
|
|
----------------------
|
|
|
|
+-------------------------+---------------------------------------------------------------------------------+-------------+
|
|
| :ref:`bool<class_bool>` | :ref:`allow_object_decoding<class_PacketPeer_property_allow_object_decoding>` | ``false`` |
|
|
+-------------------------+---------------------------------------------------------------------------------+-------------+
|
|
| :ref:`int<class_int>` | :ref:`encode_buffer_max_size<class_PacketPeer_property_encode_buffer_max_size>` | ``8388608`` |
|
|
+-------------------------+---------------------------------------------------------------------------------+-------------+
|
|
|
|
Métodos
|
|
--------------
|
|
|
|
+-------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :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 **)** |
|
|
+-------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Descripciones de Propiedades
|
|
--------------------------------------------------------
|
|
|
|
.. _class_PacketPeer_property_allow_object_decoding:
|
|
|
|
- :ref:`bool<class_bool>` **allow_object_decoding**
|
|
|
|
+-----------+----------------------------------+
|
|
| *Default* | ``false`` |
|
|
+-----------+----------------------------------+
|
|
| *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 objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeer_property_encode_buffer_max_size:
|
|
|
|
- :ref:`int<class_int>` **encode_buffer_max_size**
|
|
|
|
+-----------+-----------------------------------+
|
|
| *Default* | ``8388608`` |
|
|
+-----------+-----------------------------------+
|
|
| *Setter* | set_encode_buffer_max_size(value) |
|
|
+-----------+-----------------------------------+
|
|
| *Getter* | get_encode_buffer_max_size() |
|
|
+-----------+-----------------------------------+
|
|
|
|
Tamaño máximo de la memoria intermedia permitido al codificar las :ref:`Variant<class_Variant>`\ s. Aumente este valor para soportar asignaciones de memoria más pesadas.
|
|
|
|
El método :ref:`put_var<class_PacketPeer_method_put_var>` asigna memoria en la pila, y el búfer utilizado crecerá automáticamente hasta la potencia más cercana a dos para igualar el tamaño de la :ref:`Variant<class_Variant>`. Si la :ref:`Variant<class_Variant>` es más grande que ``encode_buffer_max_size``, el método dará un error con :ref:`@GlobalScope.ERR_OUT_OF_MEMORY<class_@GlobalScope_constant_ERR_OUT_OF_MEMORY>`.
|
|
|
|
Descripciones de Métodos
|
|
------------------------------------------------
|
|
|
|
.. _class_PacketPeer_method_get_available_packet_count:
|
|
|
|
- :ref:`int<class_int>` **get_available_packet_count** **(** **)** |const|
|
|
|
|
Devuelve el número de paquetes actualmente disponibles en el ring-buffer.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeer_method_get_packet:
|
|
|
|
- :ref:`PoolByteArray<class_PoolByteArray>` **get_packet** **(** **)**
|
|
|
|
Recibe un paquete crudo.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeer_method_get_packet_error:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **get_packet_error** **(** **)** |const|
|
|
|
|
Devuelve el estado de error del último paquete recibido (a través de :ref:`get_packet<class_PacketPeer_method_get_packet>` y :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 **)**
|
|
|
|
Gets a Variant. If ``allow_objects`` (or :ref:`allow_object_decoding<class_PacketPeer_property_allow_object_decoding>`) is ``true``, decoding objects is allowed.
|
|
|
|
\ **Warning:** Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeer_method_put_packet:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **put_packet** **(** :ref:`PoolByteArray<class_PoolByteArray>` buffer **)**
|
|
|
|
Envía un paquete crudo.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeer_method_put_var:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **put_var** **(** :ref:`Variant<class_Variant>` var, :ref:`bool<class_bool>` full_objects=false **)**
|
|
|
|
Sends a :ref:`Variant<class_Variant>` as a packet. If ``full_objects`` (or :ref:`allow_object_decoding<class_PacketPeer_property_allow_object_decoding>`) is ``true``, encoding objects is allowed (and can potentially include code).
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|