Class SteamTransport
Transport to allow for using Multiplayer Engine for Steam for Netcode for GameObjects.
Inheritance
Namespace: KaijuSolutions.SteamMultiplayerEngine.NetcodeForGameObjects
Syntax
public sealed class SteamTransport : NetworkTransport
Fields
autoConnect
If we want to automatically connect with Netcode for GameObjects when we join a lobby. Disabling could be used to implement a waiting room where players could choose characters or ready up before starting the actual game.
Declaration
public bool autoConnect
Field Value
Type | Description |
---|---|
System.Boolean |
autoDisconnect
If we want to automatically disconnect from the lobby when Netcode for GameObjects. Disabling could allow you to implement a character select screen or ready up screen you can return to or attempt to create custom host migration.
Declaration
public bool autoDisconnect
Field Value
Type | Description |
---|---|
System.Boolean |
NetcodeIdKey
Lobby member data key to sync the Netcode for GameObjects ID. Note that as this is not directly part of the core library, there are no blocks stopping you from manually setting this elsewhere; you must ensure that yourself.
Declaration
public const string NetcodeIdKey = "_i"
Field Value
Type | Description |
---|---|
System.String |
Properties
Channel
What channel to send and receive messages on. Ensure this is different from the lifetime channel and the voice channel on the SteamManager.
Declaration
public int Channel { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsSupported
This transport works if we are in a lobby. There is no use in manually accessing this with Multiplayer Engine for Steam.
Declaration
public override bool IsSupported { get; }
Property Value
Type | Description |
---|---|
System.Boolean | If we are in a lobby. |
Level
Netcode for GameObjects defines its own log level, so this integration uses it.
Declaration
public static LogLevel Level { get; }
Property Value
Type | Description |
---|---|
LogLevel |
Lifetime
What channel to use for connection and disconnect messages. Ensure this is different from the regular channel and the voice channel on the SteamManager.
Declaration
public int Lifetime { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
ServerClientId
The lobby owner's ID. There is no use in manually accessing this with Multiplayer Engine for Steam.
Declaration
public override ulong ServerClientId { get; }
Property Value
Type | Description |
---|---|
System.UInt64 |
Methods
Assign()
Assign this as the transport.
Declaration
public bool Assign()
Returns
Type | Description |
---|---|
System.Boolean | If this was assigned or already was assigned. |
AssignBindable()
Assign this as the transport.
Declaration
public void AssignBindable()
Connect()
Handle manually starting Netcode for GameObjects if auto connect is disabled.
Declaration
public static bool Connect()
Returns
Type | Description |
---|---|
System.Boolean | If the networking was started or was already running. |
ConnectBindable()
Handle manually starting Netcode for GameObjects if auto connect is disabled.
Declaration
public static void ConnectBindable()
Disconnect()
Handle manually stopping Netcode for GameObjects.
Declaration
public void Disconnect()
DisconnectLocalClient()
Disconnects the local client from the server. There is no use in manually accessing this with Multiplayer Engine for Steam.
Declaration
public override void DisconnectLocalClient()
DisconnectRemoteClient(UInt64)
Disconnects a client from the server. There is no use in manually calling this with Multiplayer Engine for Steam.
Declaration
public override void DisconnectRemoteClient(ulong clientId)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | clientId | The client to disconnect. |
GetCurrentRtt(UInt64)
Not implemented for Steam, always returning zero. There is no use in manually accessing this with Multiplayer Engine for Steam.
Declaration
public override ulong GetCurrentRtt(ulong clientId)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | clientId | The unused client ID. |
Returns
Type | Description |
---|---|
System.UInt64 | Zero. |
Initialize(NetworkManager)
Initializes the transport. There is no use in manually accessing this with Multiplayer Engine for Steam.
Declaration
public override void Initialize(NetworkManager networkManager = null)
Parameters
Type | Name | Description |
---|---|---|
NetworkManager | networkManager | The network manager. |
NetcodeToSteam(UInt64)
Get the corresponding Steam ID for a Netcode for GameObjects ID.
Declaration
public static ulong NetcodeToSteam(ulong netcode)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | netcode | The Netcode for GameObjects ID. |
Returns
Type | Description |
---|---|
System.UInt64 | The associated Steam ID or zero if there is no match. |
OnCurrentTopology()
Invoked to acquire the network topology for the current network session. There is no use in manually accessing this with Multiplayer Engine for Steam.
Declaration
protected override NetworkTopologyTypes OnCurrentTopology()
Returns
Type | Description |
---|---|
NetworkTopologyTypes | The network topology. |
PollEvent(out UInt64, out ArraySegment<Byte>, out Single)
Polls for incoming events, with an extra output parameter to report the precise time the event was received. There is no use in manually accessing this.
Declaration
public override NetworkEvent PollEvent(out ulong clientId, out ArraySegment<byte> payload, out float receiveTime)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | clientId | The clientId this event is for. |
ArraySegment<System.Byte> | payload | The incoming data payload. |
System.Single | receiveTime | The time the event was received, as reported by Time.realtimeSinceStartup. |
Returns
Type | Description |
---|---|
NetworkEvent | Returns the event type. |
Send(UInt64, ArraySegment<Byte>, NetworkDelivery)
Send a payload to the specified client. There is no use in manually calling this.
Declaration
public override void Send(ulong clientId, ArraySegment<byte> payload, NetworkDelivery networkDelivery)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | clientId | The clientId to send to. |
ArraySegment<System.Byte> | payload | The data to send. |
NetworkDelivery | networkDelivery | The delivery type (QoS) to send data with. |
Shutdown()
Shuts down the transport. There is no use in manually calling this with Multiplayer Engine for Steam.
Declaration
public override void Shutdown()
StartClient()
Connects the client to the server. There is no use in manually accessing this with Multiplayer Engine for Steam.
Declaration
public override bool StartClient()
Returns
Type | Description |
---|---|
System.Boolean | Returns success or failure. |
StartServer()
Starts to listening for incoming clients. There is no use in manually accessing this with Multiplayer Engine for Steam.
Declaration
public override bool StartServer()
Returns
Type | Description |
---|---|
System.Boolean | Returns success or failure. |
SteamToNetcode(UInt64)
Get the corresponding Netcode for GameObjects ID for a Steam ID.
Declaration
public static ulong SteamToNetcode(ulong steam)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | steam | The Steam ID. |
Returns
Type | Description |
---|---|
System.UInt64 | The associated Netcode for GameObjects ID or the max value if there is no match. |
Events
OnStarted
Callback for when the Netcode for GameObjects instance has started.
Declaration
public static event SteamManager.EmptyEventHandler OnStarted
Event Type
Type | Description |
---|---|
SteamManager.EmptyEventHandler |
OnStopped
Callback for when the Netcode for GameObjects instance has stopped.
Declaration
public static event SteamManager.EmptyEventHandler OnStopped
Event Type
Type | Description |
---|---|
SteamManager.EmptyEventHandler |
OnStopping
Callback for when the networking is shutting down in case data needs to be serialized for host migration.
Declaration
public static event SteamManager.EmptyEventHandler OnStopping
Event Type
Type | Description |
---|---|
SteamManager.EmptyEventHandler |