PacketPeer

package
v0.0.0-...-59761c8 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package PacketPeer provides methods for working with PacketPeer 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
	AsPacketPeer() Instance
}

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 New

func New() Instance

func (Instance) AsObject

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

func (Instance) AsPacketPeer

func (self Instance) AsPacketPeer() Instance

func (Instance) AsRefCounted

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

func (Instance) EncodeBufferMaxSize

func (self Instance) EncodeBufferMaxSize() int

func (Instance) GetAvailablePacketCount

func (self Instance) GetAvailablePacketCount() int

Returns the number of packets currently available in the ring-buffer.

func (Instance) GetPacket

func (self Instance) GetPacket() []byte

Gets a raw packet.

func (Instance) GetPacketError

func (self Instance) GetPacketError() error

Returns the error state of the last packet received (via [method get_packet] and [method get_var]).

func (Instance) GetVar

func (self Instance) GetVar() any

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) PutPacket

func (self Instance) PutPacket(buffer []byte) error

Sends a raw packet.

func (Instance) PutVar

func (self Instance) PutVar(v any) error

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.

func (Instance) SetEncodeBufferMaxSize

func (self Instance) SetEncodeBufferMaxSize(value int)

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