StreamPeer

package
v0.0.0-...-ae8aae0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package StreamPeer provides methods for working with StreamPeer object instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsStreamPeer() Instance
}

type Error

type Error = gd.Error //gd:Error
const (
	/*Methods that return [enum Error] return [constant OK] when no error occurred.
	  Since [constant OK] has value 0, and all other error constants are positive integers, it can also be used in boolean checks.
	  [b]Example:[/b]
	  [codeblock]
	  var error = method_that_returns_error()
	  if error != OK:
	      printerr("Failure!")

	  # Or, alternatively:
	  if error:
	      printerr("Still failing!")
	  [/codeblock]
	  [b]Note:[/b] Many functions do not return an error code, but will print error messages to standard output.*/
	Ok Error = 0
	/*Generic error.*/
	Failed Error = 1
	/*Unavailable error.*/
	ErrUnavailable Error = 2
	/*Unconfigured error.*/
	ErrUnconfigured Error = 3
	/*Unauthorized error.*/
	ErrUnauthorized Error = 4
	/*Parameter range error.*/
	ErrParameterRangeError Error = 5
	/*Out of memory (OOM) error.*/
	ErrOutOfMemory Error = 6
	/*File: Not found error.*/
	ErrFileNotFound Error = 7
	/*File: Bad drive error.*/
	ErrFileBadDrive Error = 8
	/*File: Bad path error.*/
	ErrFileBadPath Error = 9
	/*File: No permission error.*/
	ErrFileNoPermission Error = 10
	/*File: Already in use error.*/
	ErrFileAlreadyInUse Error = 11
	/*File: Can't open error.*/
	ErrFileCantOpen Error = 12
	/*File: Can't write error.*/
	ErrFileCantWrite Error = 13
	/*File: Can't read error.*/
	ErrFileCantRead Error = 14
	/*File: Unrecognized error.*/
	ErrFileUnrecognized Error = 15
	/*File: Corrupt error.*/
	ErrFileCorrupt Error = 16
	/*File: Missing dependencies error.*/
	ErrFileMissingDependencies Error = 17
	/*File: End of file (EOF) error.*/
	ErrFileEof Error = 18
	/*Can't open error.*/
	ErrCantOpen Error = 19
	/*Can't create error.*/
	ErrCantCreate Error = 20
	/*Query failed error.*/
	ErrQueryFailed Error = 21
	/*Already in use error.*/
	ErrAlreadyInUse Error = 22
	/*Locked error.*/
	ErrLocked Error = 23
	/*Timeout error.*/
	ErrTimeout Error = 24
	/*Can't connect error.*/
	ErrCantConnect Error = 25
	/*Can't resolve error.*/
	ErrCantResolve Error = 26
	/*Connection error.*/
	ErrConnectionError Error = 27
	/*Can't acquire resource error.*/
	ErrCantAcquireResource Error = 28
	/*Can't fork process error.*/
	ErrCantFork Error = 29
	/*Invalid data error.*/
	ErrInvalidData Error = 30
	/*Invalid parameter error.*/
	ErrInvalidParameter Error = 31
	/*Already exists error.*/
	ErrAlreadyExists Error = 32
	/*Does not exist error.*/
	ErrDoesNotExist Error = 33
	/*Database: Read error.*/
	ErrDatabaseCantRead Error = 34
	/*Database: Write error.*/
	ErrDatabaseCantWrite Error = 35
	/*Compilation failed error.*/
	ErrCompilationFailed Error = 36
	/*Method not found error.*/
	ErrMethodNotFound Error = 37
	/*Linking failed error.*/
	ErrLinkFailed Error = 38
	/*Script failed error.*/
	ErrScriptFailed Error = 39
	/*Cycling link (import cycle) error.*/
	ErrCyclicLink Error = 40
	/*Invalid declaration error.*/
	ErrInvalidDeclaration Error = 41
	/*Duplicate symbol error.*/
	ErrDuplicateSymbol Error = 42
	/*Parse error.*/
	ErrParseError Error = 43
	/*Busy error.*/
	ErrBusy Error = 44
	/*Skip error.*/
	ErrSkip Error = 45
	/*Help error. Used internally when passing [code]--version[/code] or [code]--help[/code] as executable options.*/
	ErrHelp Error = 46
	/*Bug error, caused by an implementation issue in the method.
	  [b]Note:[/b] If a built-in method returns this code, please open an issue on [url=https://github.com/godotengine/godot/issues]the GitHub Issue Tracker[/url].*/
	ErrBug Error = 47
	/*Printer on fire error (This is an easter egg, no built-in methods return this error code).*/
	ErrPrinterOnFire Error = 48
)

type Instance

type Instance [1]gdclass.StreamPeer

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. [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsStreamPeer

func (self Instance) AsStreamPeer() Instance

func (Instance) BigEndian

func (self Instance) BigEndian() bool

func (Instance) Get16

func (self Instance) Get16() int

Gets a signed 16-bit value from the stream.

func (Instance) Get32

func (self Instance) Get32() int

Gets a signed 32-bit value from the stream.

func (Instance) Get64

func (self Instance) Get64() int

Gets a signed 64-bit value from the stream.

func (Instance) Get8

func (self Instance) Get8() int

Gets a signed byte from the stream.

func (Instance) GetAvailableBytes

func (self Instance) GetAvailableBytes() int

Returns the number of bytes this [StreamPeer] has available.

func (Instance) GetData

func (self Instance) GetData(bytes int) []any

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

func (Instance) GetDouble

func (self Instance) GetDouble() Float.X

Gets a double-precision float from the stream.

func (Instance) GetFloat

func (self Instance) GetFloat() Float.X

Gets a single-precision float from the stream.

func (Instance) GetPartialData

func (self Instance) GetPartialData(bytes int) []any

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 [enum Error] code, and a data array.

func (Instance) GetString

func (self Instance) GetString() string

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

func (Instance) GetU16

func (self Instance) GetU16() int

Gets an unsigned 16-bit value from the stream.

func (Instance) GetU32

func (self Instance) GetU32() int

Gets an unsigned 32-bit value from the stream.

func (Instance) GetU64

func (self Instance) GetU64() int

Gets an unsigned 64-bit value from the stream.

func (Instance) GetU8

func (self Instance) GetU8() int

Gets an unsigned byte from the stream.

func (Instance) GetUtf8String

func (self Instance) GetUtf8String() string

Gets a UTF-8 string with byte-length [param bytes] from the stream (this decodes the string sent as UTF-8). If [param bytes] is negative (default) the length will be read from the stream using the reverse process of [method put_utf8_string].

func (Instance) GetVar

func (self Instance) GetVar() any

Gets a Variant from the stream. If [param allow_objects] is [code]true[/code], decoding objects is allowed. Internally, this uses the same decoding mechanism as the [method @GlobalScope.bytes_to_var] method. [b]Warning:[/b] 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.

func (Instance) Put16

func (self Instance) Put16(value int)

Puts a signed 16-bit value into the stream.

func (Instance) Put32

func (self Instance) Put32(value int)

Puts a signed 32-bit value into the stream.

func (Instance) Put64

func (self Instance) Put64(value int)

Puts a signed 64-bit value into the stream.

func (Instance) Put8

func (self Instance) Put8(value int)

Puts a signed byte into the stream.

func (Instance) PutData

func (self Instance) PutData(data []byte) error

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

func (Instance) PutDouble

func (self Instance) PutDouble(value Float.X)

Puts a double-precision float into the stream.

func (Instance) PutFloat

func (self Instance) PutFloat(value Float.X)

Puts a single-precision float into the stream.

func (Instance) PutPartialData

func (self Instance) PutPartialData(data []byte) []any

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 [enum Error] code and an integer, describing how much data was actually sent.

func (Instance) PutString

func (self Instance) PutString(value string)

Puts a zero-terminated ASCII string into the stream prepended by a 32-bit unsigned integer representing its size. [b]Note:[/b] To put an ASCII string without prepending its size, you can use [method put_data]: [codeblocks] [gdscript] put_data("Hello world".to_ascii_buffer()) [/gdscript] [csharp] PutData("Hello World".ToAsciiBuffer()); [/csharp] [/codeblocks]

func (Instance) PutU16

func (self Instance) PutU16(value int)

Puts an unsigned 16-bit value into the stream.

func (Instance) PutU32

func (self Instance) PutU32(value int)

Puts an unsigned 32-bit value into the stream.

func (Instance) PutU64

func (self Instance) PutU64(value int)

Puts an unsigned 64-bit value into the stream.

func (Instance) PutU8

func (self Instance) PutU8(value int)

Puts an unsigned byte into the stream.

func (Instance) PutUtf8String

func (self Instance) PutUtf8String(value string)

Puts a zero-terminated UTF-8 string into the stream prepended by a 32 bits unsigned integer representing its size. [b]Note:[/b] To put a UTF-8 string without prepending its size, you can use [method put_data]: [codeblocks] [gdscript] put_data("Hello world".to_utf8_buffer()) [/gdscript] [csharp] PutData("Hello World".ToUtf8Buffer()); [/csharp] [/codeblocks]

func (Instance) PutVar

func (self Instance) PutVar(value any)

Puts a Variant into the stream. If [param full_objects] is [code]true[/code] encoding objects is allowed (and can potentially include code). Internally, this uses the same encoding mechanism as the [method @GlobalScope.var_to_bytes] method.

func (Instance) SetBigEndian

func (self Instance) SetBigEndian(value bool)

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL