Documentation
¶
Overview ¶
Package PacketPeer provides methods for working with PacketPeer object instances.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsPacketPeer() Instance
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) EncodeBufferMaxSize() int
- func (self Instance) GetAvailablePacketCount() int
- func (self Instance) GetPacket() []byte
- func (self Instance) GetPacketError() error
- func (self Instance) GetVar() any
- func (self Instance) ID() ID
- func (self Instance) PutPacket(buffer []byte) error
- func (self Instance) PutVar(v any) error
- func (self Instance) SetEncodeBufferMaxSize(value int)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) Virtual(name string) reflect.Value
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 Expanded ¶
type Expanded [1]gdclass.PacketPeer
func (Expanded) GetVar ¶
Gets a Variant. 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.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsPacketPeer ¶
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.PacketPeer
PacketPeer is an abstraction and base class for packet-based protocols (such as UDP). It provides an API for sending and receiving packets both as raw data or variables. This makes it easy to transfer data over a protocol, without having to encode data as low-level bytes or having to worry about network ordering. [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 (Instance) AsPacketPeer ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) EncodeBufferMaxSize ¶
func (Instance) GetAvailablePacketCount ¶
Returns the number of packets currently available in the ring-buffer.
func (Instance) GetPacketError ¶
Returns the error state of the last packet received (via [method get_packet] and [method get_var]).
func (Instance) GetVar ¶
Gets a Variant. 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) PutVar ¶
Sends a [Variant] as a packet. 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.