reckfellENGINE

MultiplayerApi

The context for network peers, sender identity and RPC.

On this page
class MultiplayerApiReckfellSharpInherits RefCounted

Connects MultiplayerPeer to high-level networking. EntityTree normally polls APIs; SetMultiplayer can assign independent APIs to separate branches. A process and an API instance are different concepts.

GetRemoteSenderId identifies the sender in the current network handler; capture it before deferred work. AnyPeer is not account authentication. Coordinate RPC configuration, relative paths and authoritative server state.

Practical guide.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Properties1

MultiplayerPeerProperty
# MultiplayerPeer
C#
public MultiplayerPeer MultiplayerPeer { get; set; }

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 MultiplayerApi.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.

Methods14

CreateDefaultInterfaceMultiplayerApi
# CreateDefaultInterface
C#
public static MultiplayerApi CreateDefaultInterface();

Returns a new instance of the default MultiplayerAPI.

Returns MultiplayerApi
GetDefaultInterfaceStringName
# GetDefaultInterface
C#
public static StringName GetDefaultInterface();

Returns the default MultiplayerAPI implementation class name. This is usually "SceneMultiplayer" when SceneMultiplayer is available. See MultiplayerApi.SetDefaultInterface.

Returns StringName
GetMultiplayerPeerMultiplayerPeer
# GetMultiplayerPeer
C#
public MultiplayerPeer GetMultiplayerPeer();
Returns MultiplayerPeer
GetPeersint[]
# GetPeers
C#
public int[] GetPeers();

Returns the peer IDs of all connected peers of this MultiplayerAPI's MultiplayerApi.MultiplayerPeer.

Returns int[]
GetRemoteSenderIdint
# GetRemoteSenderId
C#
public int GetRemoteSenderId();

Sender ID in the current incoming-call context. Capture before deferred work; a client-supplied playerId field does not replace it.

Returns int
GetUniqueIdint
# GetUniqueId
C#
public int GetUniqueId();

Local peer ID in the current session. The server uses 1. Not a persistent account, save or game-object ID.

Returns int
HasMultiplayerPeerbool
# HasMultiplayerPeer
C#
public bool HasMultiplayerPeer();

Returns true if there is a MultiplayerApi.MultiplayerPeer set.

Returns bool
IsServerbool
# IsServer
C#
public bool IsServer();

Returns true if this MultiplayerAPI's MultiplayerApi.MultiplayerPeer is valid and in server mode (listening for connections).

Returns bool
ObjectConfigurationAddError
# ObjectConfigurationAdd
C#
public Error ObjectConfigurationAdd(ReckfellObject @object, Variant configuration);

Notifies the MultiplayerAPI of a new configuration for the given object. This method is used internally by EntityTree to configure the root path for this MultiplayerAPI (passing null and a valid EntityPath as configuration). 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. Note: This method is mostly relevant when extending or overriding the MultiplayerAPI behavior via MultiplayerApiExtension.

Parameters
NameTypeDefault
objectReckfellObject—
configurationVariant—
Returns Error
ObjectConfigurationRemoveError
# ObjectConfigurationRemove
C#
public Error ObjectConfigurationRemove(ReckfellObject @object, Variant configuration);

Notifies the MultiplayerAPI to remove a configuration for the given object. This method is used internally by EntityTree to configure the root path for this MultiplayerAPI (passing null and an empty EntityPath as configuration). 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. Note: This method is mostly relevant when extending or overriding the MultiplayerAPI behavior via MultiplayerApiExtension.

Parameters
NameTypeDefault
objectReckfellObject—
configurationVariant—
Returns Error
PollError
# Poll
C#
public Error Poll();

Advances network events/API. EntityTree normally polls; coordinate manual polling with MultiplayerPoll and lifetime.

Returns Error
RpcError
# Rpc
C#
public Error Rpc(int peer, ReckfellObject @object, StringName method, Reckfell.Collections.Array arguments = null);

Sends an RPC to the target peer. The given method will be called on the remote object with the provided arguments. The RPC may also be called locally depending on the implementation and RPC configuration. See Entity.Rpc and Entity.RpcConfig. Note: Prefer using Entity.Rpc, Entity.RpcId, or my_method.rpc(peer, arg1, arg2, ...) (in C#), since they are faster. This method is mostly useful in conjunction with MultiplayerApiExtension when extending or replacing the multiplayer capabilities.

Parameters
NameTypeDefault
peerint—
objectReckfellObject—
methodStringName—
argumentsReckfell.Collections.Arraynull
Returns Error
SetDefaultInterfacevoid
# SetDefaultInterface
C#
public static void SetDefaultInterface(StringName interfaceName);

Sets the default MultiplayerAPI implementation class. This method can be used by modules and extensions to configure which implementation will be used by EntityTree when the engine starts.

Parameters
NameTypeDefault
interfaceNameStringName—
SetMultiplayerPeervoid
# SetMultiplayerPeer
C#
public void SetMultiplayerPeer(MultiplayerPeer peer);
Parameters
NameTypeDefault
peerMultiplayerPeer—

Signals and events5

ConnectedToServerEvent
# ConnectedToServer
C#
public event Action ConnectedToServer;

Successful client API connection signal. Does not establish account authentication, level loading or every gameplay entity being ready.

ConnectionFailedEvent
# ConnectionFailed
C#
public event Action ConnectionFailed;

Emitted when this MultiplayerAPI's MultiplayerApi.MultiplayerPeer fails to establish a connection to a server. Only emitted on clients.

PeerConnectedEvent
# PeerConnected
C#
public event MultiplayerApi.PeerConnectedEventHandler PeerConnected;

Emitted when this MultiplayerAPI's MultiplayerApi.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).

Handler parameters
NameTypeDefault
idlong—
PeerDisconnectedEvent
# PeerDisconnected
C#
public event MultiplayerApi.PeerDisconnectedEventHandler PeerDisconnected;

Reports a peer leaving. Clean associated game data; publish final state and mutate APIs in a coordinated phase.

Handler parameters
NameTypeDefault
idlong—
ServerDisconnectedEvent
# ServerDisconnected
C#
public event Action ServerDisconnected;

Emitted when this MultiplayerAPI's MultiplayerApi.MultiplayerPeer disconnects from server. Only emitted on clients.

MultiplayerApi.RpcMode

ValueDescription
AnyPeer = 1

Used with Entity.RpcConfig to set a method to be callable remotely by any peer. Analogous to the @rpc("any_peer") annotation. Calls are accepted from all remote peers, no matter if they are node's authority or not.

Authority = 2

Used with Entity.RpcConfig to set a method to be callable remotely only by the current multiplayer authority (which is the server by default). Analogous to the @rpc("authority") annotation. See Entity.SetMultiplayerAuthority.

Disabled = 0

Used with Entity.RpcConfig to disable a method or property for all RPC calls, making it unavailable. Default for all methods.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.

MultiplayerApi — C# API · Reckfell