PacketPeer
Abstraction and base class for packet-based protocols.
PacketPeer.swift:20class 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.
Superclasses
class RefCounted
Base class for reference-counted objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var encodeBufferMaxSize: Int32
Maximum buffer size allowed when encoding
Variant
s. Raise this value to support heavier memory allocations.func getAvailablePacketCount(
) -> Int32 Returns the number of packets currently available in the ring-buffer.
func getPacket(
) -> PackedByteArray Gets a raw packet.
func getPacketError(
) -> GodotError Returns the error state of the last packet received (via
getPacket
andgetVar(allowObjects:)
).func getVar(allowObjects: Bool
) -> Variant Gets a Variant. If
allowObjects
istrue
, decoding objects is allowed.func putPacket(buffer: PackedByteArray
) -> GodotError Sends a raw packet.
func putVar(Variant, fullObjects: Bool
) -> GodotError Sends a
Variant
as a packet. IffullObjects
istrue
, encoding objects is allowed (and can potentially include code).
Subclasses
class ENetPacketPeer
A wrapper class for an ENetPeer.
class MultiplayerPeer
Abstract class for specialized
PacketPeer
s used by theMultiplayerAPI
.class PacketPeerDTLS
DTLS packet peer.
class PacketPeerExtension
class PacketPeerStream
Wrapper to use a PacketPeer over a StreamPeer.
class PacketPeerUDP
UDP packet peer.
class WebRTCDataChannel
class WebSocketPeer
A WebSocket connection.