API ReferenceSandbox.Network

GameNetworkSystemclass

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

objectGameNetworkSystem
Namespace
Sandbox.Network
Assembly
Sandbox.Engine
Declaration
public abstract class Sandbox.Network.GameNetworkSystem

Constructors1

Showing 1 constructors

Methods26

Showing 26 methods

public virtual bool AcceptConnection(Sandbox.Connection channel, string reason)PUBLICVIRTUAL

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

ParameterTypeDescription
channelConnection
reasonstringThe reason to display to the client.
Returns:bool

public void Broadcast(T obj, System.Nullable`1<Sandbox.Connection.Filter> filter = null)PUBLIC

ParameterTypeDescription
objT
filter = nullNullable<Filter>
Returns:void

public static void CreateLobby()PUBLICSTATICOBSOLETE

Obsolete: Moved to Networking.CreateLobby

Returns:void

public static void Disconnect()PUBLICSTATICOBSOLETE

Obsolete: Moved to Networking.Disconnect

Returns:void

public virtual void Dispose()PUBLICVIRTUAL

Returns:void

public virtual void OnBecameHost(Sandbox.Connection previousHost)PUBLICVIRTUAL

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

ParameterTypeDescription
previousHostConnection
Returns:void

public virtual void OnConnected(Sandbox.Connection client)PUBLICVIRTUAL

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

ParameterTypeDescription
clientConnection
Returns:void

public virtual void OnHostChanged(Sandbox.Connection previousHost, Sandbox.Connection newHost)PUBLICVIRTUAL

The current host has been changed.

ParameterTypeDescription
previousHostConnection
newHostConnection
Returns:void

public virtual void OnInitialize()PUBLICVIRTUAL

Called when the network system should handle initialization.

Returns:void

public virtual void OnJoined(Sandbox.Connection client)PUBLICVIRTUAL

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.

ParameterTypeDescription
clientConnection
Returns:void

public virtual void OnLeave(Sandbox.Connection client)PUBLICVIRTUAL

A client has disconnected from the server.

ParameterTypeDescription
clientConnection
Returns:void

public virtual System.IDisposable Push()PUBLICVIRTUAL

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

Returns:IDisposable

public static System.Threading.Tasks.Task`1<System.Collections.Generic.List`1<Sandbox.Network.LobbyInformation>> QueryLobbies()PUBLICSTATICOBSOLETE

Obsolete: Moved to Networking.QueryLobbies

Returns:Task<List<LobbyInformation>>

public void Send(System.Guid connectionId, T obj)PUBLIC

ParameterTypeDescription
connectionIdGuid
objT
Returns:void

public virtual System.Threading.Tasks.Task SetSnapshotAsync(Sandbox.Network.SnapshotMsg data)PUBLICVIRTUAL

ParameterTypeDescription
dataSnapshotMsg
Returns:Task

protected virtual void Tick()PROTECTEDVIRTUAL

Called every frame

Returns:void

public static System.Threading.Tasks.Task`1<bool> TryConnectSteamId(ulong steamId)PUBLICSTATICOBSOLETE

Obsolete: Moved to Networking.Connect

ParameterTypeDescription
steamIdulong
Returns:Task<bool>

Properties4

Showing 4 properties

public static bool Sandbox.Network.GameNetworkSystem.IsActive { get; set; }PUBLICSTATICGETSETOBSOLETE

True if we're currently connected etc

Obsolete: Moved to Networking.IsActive

Returns:bool

public static bool Sandbox.Network.GameNetworkSystem.IsClient { get; set; }PUBLICSTATICGETSETOBSOLETE

True if we're connected to a server and not the host.

Obsolete: Moved to Networking.IsClient

Returns:bool

public static bool Sandbox.Network.GameNetworkSystem.IsConnecting { get; set; }PUBLICSTATICGETSETOBSOLETE

True if we're currently connecting to the server

Obsolete: Moved to Networking.IsConnecting

Returns:bool

public static bool Sandbox.Network.GameNetworkSystem.IsHost { get; set; }PUBLICSTATICGETSETOBSOLETE

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.

Obsolete: Moved to Networking.IsHost

Returns:bool

On this page

Constructorspublic GameNetworkSystem()Methodspublic virtual System.Boolean AcceptConnection(Sandbox.Connection channel, System.String reason)public System.Void AddHandler(System.Action`2<T,Sandbox.Connection> handler)public System.Void AddHandler(System.Action`3<T,Sandbox.Connection,System.Guid> handler)public System.Void AddHandler(System.Func`4<T,Sandbox.Connection,System.Guid,System.Threading.Tasks.Task> handler)public System.Void Broadcast(T obj, System.Nullable`1<Sandbox.Connection.Filter> filter = null)public System.Void BroadcastRaw(Sandbox.ByteStream msg, System.Nullable`1<Sandbox.Connection.Filter> filter = null)public static System.Void Connect(System.String target)public static System.Void Connect(System.UInt64 steamid)public static System.Void CreateLobby()public static System.Void Disconnect()public virtual System.Void Dispose()public virtual System.Void GetMountedVPKs(Sandbox.Connection source, Sandbox.Network.MountedVPKsResponse msg)public virtual System.Void GetSnapshot(Sandbox.Connection source, Sandbox.Network.SnapshotMsg msg)public virtual System.Threading.Tasks.Task MountVPKs(Sandbox.Connection source, Sandbox.Network.MountedVPKsResponse msg)public virtual System.Void OnBecameHost(Sandbox.Connection previousHost)public virtual System.Void OnConnected(Sandbox.Connection client)public virtual System.Void OnHostChanged(Sandbox.Connection previousHost, Sandbox.Connection newHost)public virtual System.Void OnInitialize()public virtual System.Void OnJoined(Sandbox.Connection client)public virtual System.Void OnLeave(Sandbox.Connection client)public virtual System.IDisposable Push()public static System.Threading.Tasks.Task`1<System.Collections.Generic.List`1<Sandbox.Network.LobbyInformation>> QueryLobbies()public System.Void Send(System.Guid connectionId, T obj)public virtual System.Threading.Tasks.Task SetSnapshotAsync(Sandbox.Network.SnapshotMsg data)protected virtual System.Void Tick()public static System.Threading.Tasks.Task`1<System.Boolean> TryConnectSteamId(System.UInt64 steamId)Propertiespublic static System.Boolean Sandbox.Network.GameNetworkSystem.IsActive { get; set; }public static System.Boolean Sandbox.Network.GameNetworkSystem.IsClient { get; set; }public static System.Boolean Sandbox.Network.GameNetworkSystem.IsConnecting { get; set; }public static System.Boolean Sandbox.Network.GameNetworkSystem.IsHost { get; set; }Metadata