class-description NEWS COMMUNITY STORE TUTORIALS SIGN UP LOGIN LOGOUT ROKOJORI NEWSLETTER SIGN UP LOGIN LOGOUT NEWS COMMUNITY STORE TUTORIALS TOGGLE FULLSCREEN VOLLBILD AN/AUS ObjectRefCounted StreamPeer
Abstract base class for interacting with streams.

StreamPeer is an abstract base class mostly used for stream-based protocols (such as TCP). It provides an API for sending and receiving data through streams as raw data or strings.

bool big_endian<>():bool

If true, this StreamPeer will using big-endian format for encoding and decoding.

int get_8<>():int

Gets a signed byte from the stream.

int get_16<>():int

Gets a signed 16-bit value from the stream.

int get_32<>():int

Gets a signed 32-bit value from the stream.

int get_64<>():int

Gets a signed 64-bit value from the stream.

int get_available_bytes<>():int

Returns the number of bytes this StreamPeer has available.

Array get_data<>( int bytes=, bytes:int=, ):Array

Returns a chunk data with the received bytes. The number of bytes to be received can be requested in the bytes argument. If not enough bytes are available, the function will block until the desired amount is received. This function returns two values, an Error code and a data array.

float get_double<>():float

Gets a double-precision float from the stream.

float get_float<>():float

Gets a single-precision float from the stream.

Array get_partial_data<>( int bytes=, bytes:int=, ):Array

Returns a chunk data with the received bytes. The number of bytes to be received can be requested in the "bytes" argument. If not enough bytes are available, the function will return how many were actually received. This function returns two values, an Error code, and a data array.

String get_string<>( int=, int:=, ):String

Gets an ASCII string with byte-length bytes from the stream. If bytes is negative (default) the length will be read from the stream using the reverse process of put_string.

int get_u8<>():int

Gets an unsigned byte from the stream.

int get_u16<>():int

Gets an unsigned 16-bit value from the stream.

int get_u32<>():int

Gets an unsigned 32-bit value from the stream.

int get_u64<>():int

Gets an unsigned 64-bit value from the stream.

String get_utf8_string<>( int=, int:=, ):String

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<>( bool allow_objects=false, allow_objects:bool=false, ):Variant

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.

void put_8<>( int value=, value:int=, ):void

Puts a signed byte into the stream.

void put_16<>( int value=, value:int=, ):void

Puts a signed 16-bit value into the stream.

void put_32<>( int value=, value:int=, ):void

Puts a signed 32-bit value into the stream.

void put_64<>( int value=, value:int=, ):void

Puts a signed 64-bit value into the stream.

Error put_data<>( PackedByteArray data=, data:PackedByteArray=, ):Error

Sends a chunk of data through the connection, blocking if necessary until the data is done sending. This function returns an Error code.

void put_double<>( float value=, value:float=, ):void

Puts a double-precision float into the stream.

void put_float<>( float value=, value:float=, ):void

Puts a single-precision float into the stream.

Array put_partial_data<>( PackedByteArray data=, data:PackedByteArray=, ):Array

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<>( String value=, value:String=, ):void

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())
void put_u8<>( int value=, value:int=, ):void

Puts an unsigned byte into the stream.

void put_u16<>( int value=, value:int=, ):void

Puts an unsigned 16-bit value into the stream.

void put_u32<>( int value=, value:int=, ):void

Puts an unsigned 32-bit value into the stream.

void put_u64<>( int value=, value:int=, ):void

Puts an unsigned 64-bit value into the stream.

void put_utf8_string<>( String value=, value:String=, ):void

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())
void put_var<>( Variant value=, value:Variant=, bool full_objects=false, full_objects:bool=false, ):void

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.




All social media brands are registrated trademarks and belong to their respective owners.





CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
We are using cookies on this site. Read more... Wir benutzen Cookies auf dieser Seite. Mehr lesen...