StreamPeer
Hereda: RefCounted < Object
Heredado por: StreamPeerBuffer, StreamPeerExtension, StreamPeerGZIP, StreamPeerTCP, StreamPeerTLS
Clase base abstracta para interactuar con tranmisiones.
Descripción
StreamPeer es una clase base abstracta utilizada principalmente para protocolos basados en tranmisiones (como TCP). Proporciona una API para enviar y recibir datos a través de tranmisiones como datos brutos o strings de texto.
Nota: Al exportar a Android, asegúrate de habilitar el permiso INTERNET en el preset de exportación de Android antes de exportar el proyecto o usar el despliegue con un solo clic. De lo contrario, la comunicación de red de cualquier tipo será bloqueada por Android.
Propiedades
|
Métodos
get_8() |
|
get_16() |
|
get_32() |
|
get_64() |
|
get_available_bytes() const |
|
get_half() |
|
get_partial_data(bytes: int) |
|
get_string(bytes: int = -1) |
|
get_u8() |
|
get_u16() |
|
get_u32() |
|
get_u64() |
|
get_utf8_string(bytes: int = -1) |
|
void |
|
void |
|
void |
|
void |
|
put_data(data: PackedByteArray) |
|
void |
put_double(value: float) |
void |
|
void |
|
put_partial_data(data: PackedByteArray) |
|
void |
put_string(value: String) |
void |
|
void |
|
void |
|
void |
|
void |
put_utf8_string(value: String) |
void |
Descripciones de Propiedades
Si es true, este StreamPeer usará el formato big-endian para codificar y decodificar.
Descripciones de Métodos
Obtiene un byte con signo del stream.
Obtiene un valor con signo de 16 bits del stream.
Obtiene un valor con signo de 32 bits del stream.
Obtiene un valor con signo de 64 bits del stream.
int get_available_bytes() const 🔗
Devuelve la cantidad de bytes que este StreamPeer tiene disponible.
Devuelve un trozo de datos con los bytes recibidos. El número de bytes a recibir puede solicitarse en el argumento bytes. Si no hay suficientes bytes disponibles, la función se bloqueará hasta que se reciba la cantidad deseada. Esta función devuelve dos valores, un código Error y un array de datos.
Consigue un real de double-precision del stream.
Consigue un real de single-precision del stream.
Obtiene un float de precisión media de la transmisión.
Array get_partial_data(bytes: int) 🔗
Devuelve un fragmento de datos con los bytes recibidos. La cantidad de bytes a recibir se puede solicitar en el argumento bytes. Si no hay suficientes bytes disponibles, la función devolverá cuántos se recibieron realmente. Esta función devuelve dos valores: un código Error y un array de datos.
String get_string(bytes: int = -1) 🔗
Obtiene una string ASCII con una longitud de bytes bytes del flujo. Si bytes es negativo (por defecto), la longitud se leerá del flujo utilizando el proceso inverso de put_string().
Obtiene un byte sin signo del stream.
Obtiene un valor de 16 bits sin signo de la corriente.
Obtiene un valor de 32 bits sin signo del stream.
Obtiene un valor de 64 bits sin signo del stream.
String get_utf8_string(bytes: int = -1) 🔗
Gets a UTF-8 string with byte-length bytes from the stream (this decodes the string sent as UTF-8). If bytes is negative (default) the length will be read from the stream using the reverse process of put_utf8_string().
Variant get_var(allow_objects: bool = false) 🔗
Gets a Variant from the stream. If allow_objects is true, decoding objects is allowed.
Internally, this uses the same decoding mechanism as the @GlobalScope.bytes_to_var() method.
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.
Pone un byte con signo en el stream.
Pone un valor con signo de 16 bits en el stream.
Pone un valor con signo de 32 bits en el stream.
Pone un valor con signo de 64 bits en el stream.
Error put_data(data: PackedByteArray) 🔗
Envía un fragmento de datos a través de la conexión, bloqueando si es necesario hasta que se terminen de enviar los datos. Esta función devuelve un código Error.
void put_double(value: float) 🔗
Pone un real de double-precision en el stream.
void put_float(value: float) 🔗
Pone un real de single-precision en el stream.
Puts a half-precision float into the stream.
Array put_partial_data(data: PackedByteArray) 🔗
Sends a chunk of data through the connection. If all the data could not be sent at once, only part of it will. This function returns two values, an Error code and an integer, describing how much data was actually sent.
void put_string(value: String) 🔗
Puts a zero-terminated ASCII string into the stream prepended by a 32-bit unsigned integer representing its size.
Note: To put an ASCII string without prepending its size, you can use put_data():
put_data("Hello world".to_ascii_buffer())
PutData("Hello World".ToAsciiBuffer());
Pone un byte sin signo en el stream.
Pone un valor de 16 bits sin signo en el stream.
Pone un valor de 32 bits sin signo en el stream.
Pone un valor de 64 bits sin signo en stream.
void put_utf8_string(value: String) 🔗
Puts a zero-terminated UTF-8 string into the stream prepended by a 32 bits unsigned integer representing its size.
Note: To put a UTF-8 string without prepending its size, you can use put_data():
put_data("Hello world".to_utf8_buffer())
PutData("Hello World".ToUtf8Buffer());
void put_var(value: Variant, full_objects: bool = false) 🔗
Puts a Variant into the stream. If full_objects is true encoding objects is allowed (and can potentially include code).
Internally, this uses the same encoding mechanism as the @GlobalScope.var_to_bytes() method.