PacketPeerUDP
UDP packet peer.
class PacketPeerUDPUDP packet peer. Can be used to send raw UDP packets as well as Variants.
UDP packet peer.
class PacketPeerUDPUDP packet peer. Can be used to send raw UDP packets as well as Variants.
import SwiftGodotFramework to write Godot Game Extensions using the Swift Programming Language.
class VariantVariant objects box various Godot Objects, you create them with one of the constructors, and you can retrieve the contents using the various extension constructors that are declared on the various types that are wrapped.
class PacketPeerAbstraction and base class for packet-based protocols.
protocol CustomStringConvertibleA type with a customized textual representation.
protocol EquatableA type that can be compared for value equality.
protocol Hashable : EquatableA 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 : VariantStorableTypes that conform to VariantRepresentable can be stored directly in Variant with no conversion. These include all of the Variant types from Godot (for example GString, Rect, Plane), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.
protocol VariantStorableTypes that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
override class var godotClassName: StringName { get }final func bind(port: Int32, bindAddress: String = "*", recvBufSize: Int32 = 65536) -> GodotError Binds this PacketPeerUDP to the specified port and bindAddress with a buffer size recvBufSize, allowing it to receive incoming packets.
final func close() Closes the PacketPeerUDP’s underlying UDP socket.
final func connectToHost(_ host: String, port: Int32) -> GodotError Calling this method connects this UDP peer to the given host/port pair. UDP is in reality connectionless, so this option only means that incoming packets from different addresses are automatically discarded, and that outgoing packets are always sent to the connected address (future calls to setDestAddress(host:port:) are not allowed). This method does not send any data to the remote peer, to do that, use putVar(_:fullObjects:) or putPacket(buffer:) as usual. See also UDPServer.
final func getLocalPort() -> Int32 Returns the local port to which this peer is bound.
final func getPacketIp() -> String Returns the IP of the remote peer that sent the last packet(that was received with getPacket or getVar(allowObjects:)).
final func getPacketPort() -> Int32 Returns the port of the remote peer that sent the last packet(that was received with getPacket or getVar(allowObjects:)).
final func isBound() -> Bool Returns whether this PacketPeerUDP is bound to an address and can receive packets.
final func isSocketConnected() -> Bool Returns true if the UDP socket is open and has been connected to a remote address. See connectToHost(_:port:).
final func joinMulticastGroup(multicastAddress: String, interfaceName: String) -> GodotError Joins the multicast group specified by multicastAddress using the interface identified by interfaceName.
final func leaveMulticastGroup(multicastAddress: String, interfaceName: String) -> GodotError Removes the interface identified by interfaceName from the multicast group specified by multicastAddress.
final func setBroadcastEnabled(_ enabled: Bool) Enable or disable sending of broadcast packets (e.g. set_dest_address("255.255.255.255", 4343). This option is disabled by default.
final func setDestAddress(host: String, port: Int32) -> GodotError Sets the destination address and port for sending packets and variables. A hostname will be resolved using DNS if needed.
final func wait() -> GodotError Waits for a packet to arrive on the bound address. See bind(port:bindAddress:recvBufSize:).