Signal2
Signal support.
MultiplayerPeer.swift:556class Signal2
Use the connect(flags:_:)
method to connect to the signal on the container object, and disconnect(_:)
to drop the connection.
You can also await the emitted
property for waiting for a single emission of the signal.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (22) members.
Types
enum ConnectionStatus
class Signal1
Signal support.
enum TransferMode
Type members
static let targetPeerBroadcast: Int
Packets are sent to all connected peers.
static let targetPeerServer: Int
Packets are sent to the remote peer acting as server.
class var godotClassName: StringName
Instance members
var peerConnected: Signal1
Emitted when a remote peer connects.
var peerDisconnected: Signal2
Emitted when a remote peer has disconnected.
var refuseNewConnections: Bool
If
true
, thisMultiplayerPeer
refuses new connections.var transferChannel: Int32
The channel to use to send packets. Many network APIs such as ENet and WebRTC allow the creation of multiple independent channels which behaves, in a way, like separate connections. This means that reliable data will only block delivery of other packets on that channel, and ordering will only be in respect to the channel the packet is being sent on. Using different channels to send different and independent state updates is a common way to optimize network usage and decrease latency in fast-paced games.
var transferMode: MultiplayerPeer.TransferMode
The manner in which to send packets to the target peer. See
TransferMode
, and thesetTargetPeer(id:)
method.func close(
) Immediately close the multiplayer peer returning to the state .connectionDisconnected. Connected peers will be dropped without emitting [signal peer_disconnected].
func disconnectPeer(Int32, force: Bool
) Disconnects the given
peer
from this host. Ifforce
istrue
the [signal peer_disconnected] signal will not be emitted for this peer.func generateUniqueId(
) -> UInt32 Returns a randomly generated integer that can be used as a network unique ID.
func getConnectionStatus(
) -> MultiplayerPeer.ConnectionStatus Returns the current state of the connection. See
ConnectionStatus
.func getPacketChannel(
) -> Int32 Returns the channel over which the next available packet was received. See
getAvailablePacketCount
.func getPacketMode(
) -> MultiplayerPeer.TransferMode Returns the transfer mode the remote peer used to send the next available packet. See
getAvailablePacketCount
.func getPacketPeer(
) -> Int32 Returns the ID of the
MultiplayerPeer
who sent the next available packet. SeegetAvailablePacketCount
.func getUniqueId(
) -> Int32 Returns the ID of this
MultiplayerPeer
.func isServerRelaySupported(
) -> Bool Returns true if the server can act as a relay in the current configuration (i.e. if the higher level
MultiplayerAPI
should notify connected clients of other peers, and implement a relay protocol to allow communication between them).func poll(
) Waits up to 1 second to receive a new network event.
func setTargetPeer(id: Int32
) Sets the peer to which packets will be sent.
Citizens in SwiftGodot
Instance members
var emitted: Void
You can await this property to wait for the signal to be emitted once
func connect(flags: Object.ConnectFlags, @escaping (_ id: Int64) -> ()
) -> Object Connects the signal to the specified callback
func disconnect(Object
) Disconnects a signal that was previously connected, the return value from calling
connect(flags:_:)