SceneMultiplayer

    High-level multiplayer API implementation.

    SceneMultiplayer.swift:27
    class SceneMultiplayer

    This class is the default implementation of MultiplayerAPI, used to provide multiplayer functionalities in Godot Engine.

    This implementation supports RPCs via Node/rpc(method:) and Node/rpcId(peerId:method:) and requires rpc(peer:object:method:arguments:) to be passed a Node (it will fail for other object types).

    This implementation additionally provide SceneTree replication via the MultiplayerSpawner and MultiplayerSynchronizer nodes, and the SceneReplicationConfig resource.

    This object emits the following signals:

    Superclasses

    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 example GString, 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.

    Types

    Type members

    Instance members

    • var allowObjectDecoding: Bool

      If true, the MultiplayerAPI will allow encoding and decoding of object during RPCs.

    • var authCallback: Callable

      The callback to execute when when receiving authentication data sent via sendAuth(id:data:). If the Callable is empty (default), peers will be automatically accepted as soon as they connect.

    • var authTimeout: Double

      If set to a value greater than 0.0, the maximum amount of time peers can stay in the authenticating state, after which the authentication will automatically fail. See the [signal peer_authenticating] and [signal peer_authentication_failed] signals.

    • var maxDeltaPacketSize: Int32

      Maximum size of each delta packet. Higher values increase the chance of receiving full updates in a single frame, but also the chance of causing networking congestion (higher latency, disconnections). See MultiplayerSynchronizer.

    • var maxSyncPacketSize: Int32

      Maximum size of each synchronization packet. Higher values increase the chance of receiving full updates in a single frame, but also the chance of packet loss. See MultiplayerSynchronizer.

    • var peerAuthenticating: Signal1

      Emitted when this MultiplayerAPI’s multiplayerPeer connects to a new peer and a valid authCallback is set. In this case, the [signal MultiplayerAPI.peer_connected] will not be emitted until completeAuth(id:) is called with given peer id. While in this state, the peer will not be included in the list returned by getPeers (but in the one returned by getAuthenticatingPeers), and only authentication data will be sent or received. See sendAuth(id:data:) for sending authentication data.

    • var peerAuthenticationFailed: Signal2

      Emitted when this MultiplayerAPI’s multiplayerPeer disconnects from a peer for which authentication had not yet completed. See [signal peer_authenticating].

    • var peerPacket: Signal3

      Emitted when this MultiplayerAPI’s multiplayerPeer receives a packet with custom data (see sendBytes(_:id:mode:channel:)). ID is the peer ID of the peer that sent the packet.

    • var refuseNewConnections: Bool

      If true, the MultiplayerAPI’s multiplayerPeer refuses new incoming connections.

    • var rootPath: NodePath

      The root path to use for RPCs and replication. Instead of an absolute path, a relative path will be used to find the node upon which the RPC should be executed.

    • var serverRelay: Bool

      Enable or disable the server feature that notifies clients of other peers’ connection/disconnection, and relays messages between them. When this option is false, clients won’t be automatically notified of other peers and won’t be able to send them packets through the server.

    • func clear()

      Clears the current SceneMultiplayer network state (you shouldn’t call this unless you know what you are doing).

    • func completeAuth(id: Int32) -> GodotError

      Mark the authentication step as completed for the remote peer identified by id. The [signal MultiplayerAPI.peer_connected] signal will be emitted for this peer once the remote side also completes the authentication. No further authentication messages are expected to be received from this peer.

    • func disconnectPeer(id: Int32)

      Disconnects the peer identified by id, removing it from the list of connected peers, and closing the underlying connection with it.

    • func getAuthenticatingPeers() -> PackedInt32Array

      Returns the IDs of the peers currently trying to authenticate with this MultiplayerAPI.

    • func sendAuth(id: Int32, data: PackedByteArray) -> GodotError

      Sends the specified data to the remote peer identified by id as part of an authentication message. This can be used to authenticate peers, and control when [signal MultiplayerAPI.peer_connected] is emitted (and the remote peer accepted as one of the connected peers).

    • func sendBytes(PackedByteArray, id: Int32, mode: MultiplayerPeer.TransferMode, channel: Int32) -> GodotError

      Sends the given raw bytes to a specific peer identified by id (see setTargetPeer(id:)). Default ID is 0, i.e. broadcast to all peers.