Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
PacketPeer¶
Inherited By: NetworkedMultiplayerPeer, PacketPeerDTLS, PacketPeerGDNative, PacketPeerStream, PacketPeerUDP, WebRTCDataChannel, 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¶
|
||
|
Métodos¶
get_available_packet_count ( ) const |
|
get_packet ( ) |
|
get_packet_error ( ) const |
|
put_packet ( PoolByteArray buffer ) |
|
Descripciones de Propiedades¶
bool allow_object_decoding
Default |
|
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 get_var and 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.
int encode_buffer_max_size
Default |
|
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 Variants. Aumente este valor para soportar asignaciones de memoria más pesadas.
El método 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 Variant. Si la Variant es más grande que encode_buffer_max_size
, el método dará un error con @GlobalScope.ERR_OUT_OF_MEMORY.
Descripciones de Métodos¶
int get_available_packet_count ( ) const
Devuelve el número de paquetes actualmente disponibles en el ring-buffer.
PoolByteArray get_packet ( )
Recibe un paquete crudo.
Error get_packet_error ( ) const
Devuelve el estado de error del último paquete recibido (a través de get_packet y get_var).
Gets a Variant. If allow_objects
(or 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.
Error put_packet ( PoolByteArray buffer )
Envía un paquete crudo.
Sends a Variant as a packet. If full_objects
(or allow_object_decoding) is true
, encoding objects is allowed (and can potentially include code).