Api Sandbox Network GameNetworkSystem
class

GameNetworkSystem

public abstract class GameNetworkSystem

An instance of this is created by the NetworkSystem when a server is joined, or created. You should not try to create this manually.

Constructors

GameNetworkSystem()

Properties

Name Type Description
IsHost static Boolean True if we can be considered the host of this session. Either we're not connected to a server, or we are and we are the host.
IsClient static Boolean True if we're connected to a server and not the host.
IsConnecting static Boolean True if we're currently connecting to the server
IsActive static Boolean True if we're currently connected etc

Methods

virtual Void Dispose()
virtual Boolean AcceptConnection(Connection channel, String reason)

Called on the host to decide whether to accept a Connection.

channel
reason — The reason to display to the client.
virtual Void GetMountedVPKs(Connection source, MountedVPKsResponse msg)
virtual Void GetSnapshot(Connection source, SnapshotMsg msg)
virtual Task SetSnapshotAsync(SnapshotMsg data)
virtual Task MountVPKs(Connection source, MountedVPKsResponse msg)
virtual Void OnInitialize()

Called when the network system should handle initialization.

virtual Void OnConnected(Connection client)

A client has connected to the server but hasn't fully finished joining yet.

virtual Void OnJoined(Connection client)

Fully joined the server. Can be called when changing the map too. The game should usually create some object for the player to control here.

virtual Void OnLeave(Connection client)

A client has disconnected from the server.

virtual Void OnBecameHost(Connection previousHost)

The host left the server and you are now in charge.

virtual Void OnHostChanged(Connection previousHost, Connection newHost)

The current host has been changed.

Void BroadcastRaw(ByteStream msg, Filter? filter = null)
Void Broadcast(T obj, Filter? filter = null)
Void Send(Guid connectionId, T obj)
virtual IDisposable Push()

Allows to push some kind of scope when reading network messages. This is useful if you need to adjust Time.Now etc.

Void AddHandler(Action<T, Connection, Guid> handler)
Void AddHandler(Func<T, Connection, Guid, Task> handler)
Void AddHandler(Action<T, Connection> handler)
static Void CreateLobby()
static List<LobbyInformation>> QueryLobbies()
static Void Disconnect()
static Void Connect(UInt64 steamid)
static Void Connect(String target)
static Task<Boolean> TryConnectSteamId(UInt64 steamId)
Assembly: Sandbox.Engine Namespace: Sandbox.Network Full Name: Sandbox.Network.GameNetworkSystem