Signal2
Signal support.
MultiplayerAPI.swift:508class 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 (21) members.
Types
enum RPCMode
class Signal1
Signal support.
Type members
static func createDefaultInterface(
) -> MultiplayerAPI? Returns a new instance of the default MultiplayerAPI.
static func getDefaultInterface(
) -> StringName Returns the default MultiplayerAPI implementation class name. This is usually
"SceneMultiplayer"
whenSceneMultiplayer
is available. SeesetDefaultInterface(interfaceName:)
.static func setDefaultInterface(interfaceName: StringName
) Sets the default MultiplayerAPI implementation class. This method can be used by modules and extensions to configure which implementation will be used by
SceneTree
when the engine starts.class var godotClassName: StringName
Instance members
var connectedToServer: SimpleSignal
Emitted when this MultiplayerAPI’s
multiplayerPeer
successfully connected to a server. Only emitted on clients.var connectionFailed: SimpleSignal
Emitted when this MultiplayerAPI’s
multiplayerPeer
fails to establish a connection to a server. Only emitted on clients.var multiplayerPeer: MultiplayerPeer?
The peer object to handle the RPC system (effectively enabling networking when set). Depending on the peer itself, the MultiplayerAPI will become a network server (check with
isServer
) and will set root node’s network mode to authority, or it will become a regular client peer. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to MultiplayerAPI’s signals.var peerConnected: Signal1
Emitted when this MultiplayerAPI’s
multiplayerPeer
connects with a new peer. ID is the peer ID of the new peer. Clients get notified when other clients connect to the same server. Upon connecting to a server, a client also receives this signal for the server (with ID being 1).var peerDisconnected: Signal2
Emitted when this MultiplayerAPI’s
multiplayerPeer
disconnects from a peer. Clients get notified when other clients disconnect from the same server.var serverDisconnected: SimpleSignal
Emitted when this MultiplayerAPI’s
multiplayerPeer
disconnects from server. Only emitted on clients.func getPeers(
) -> PackedInt32Array Returns the peer IDs of all connected peers of this MultiplayerAPI’s
multiplayerPeer
.func getRemoteSenderId(
) -> Int32 Returns the sender’s peer ID for the RPC currently being executed.
func getUniqueId(
) -> Int32 Returns the unique peer ID of this MultiplayerAPI’s
multiplayerPeer
.func hasMultiplayerPeer(
) -> Bool Returns
true
if there is amultiplayerPeer
set.func isServer(
) -> Bool Returns
true
if this MultiplayerAPI’smultiplayerPeer
is valid and in server mode (listening for connections).func objectConfigurationAdd(object: Object?, configuration: Variant
) -> GodotError Notifies the MultiplayerAPI of a new
configuration
for the givenobject
. This method is used internally bySceneTree
to configure the root path for this MultiplayerAPI (passingnull
and a validNodePath
asconfiguration
). This method can be further used by MultiplayerAPI implementations to provide additional features, refer to specific implementation (e.g.SceneMultiplayer
) for details on how they use it.func objectConfigurationRemove(object: Object?, configuration: Variant
) -> GodotError Notifies the MultiplayerAPI to remove a
configuration
for the givenobject
. This method is used internally bySceneTree
to configure the root path for this MultiplayerAPI (passingnull
and an emptyNodePath
asconfiguration
). This method can be further used by MultiplayerAPI implementations to provide additional features, refer to specific implementation (e.g.SceneMultiplayer
) for details on how they use it.func poll(
) -> GodotError Method used for polling the MultiplayerAPI. You only need to worry about this if you set
multiplayerPoll
tofalse
. By default,SceneTree
will poll its MultiplayerAPI(s) for you.func rpc(peer: Int32, object: Object?, method: StringName, arguments: GArray
) -> GodotError Sends an RPC to the target
peer
. The givenmethod
will be called on the remoteobject
with the providedarguments
. The RPC may also be called locally depending on the implementation and RPC configuration. SeeNode/rpc(method:)
andrpcConfig(method:config:)
.
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:_:)