Networkingclass

Global manager to hold and tick the singleton instance of NetworkSystem.

objectNetworking
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public static abstract sealed class Sandbox.Networking

Methods14

Showing 14 methods

public static void Disconnect()PUBLICSTATIC

Disconnect from current multiplayer session.

Returns:void

public static Sandbox.Connection FindConnection(System.Guid id)PUBLICSTATICOBSOLETE

Obsolete: Moved to Connection.Find

ParameterTypeDescription
idGuid
Returns:Connection

public static string GetData(string key, string defaultValue)PUBLICSTATIC

Get data about the current server or lobby. This data can be used for filtering when querying lobbies.

ParameterTypeDescription
keystring
defaultValuestring
Returns:string

public static System.Threading.Tasks.Task`1<bool> JoinBestLobby(string ident)PUBLICSTATIC

Try to join the best lobby. Return true on success.

ParameterTypeDescription
identstring
Returns:Task<bool>

public static void SetData(string key, string value)PUBLICSTATIC

Set data about the current server or lobby. Other players can query this when searching for a game. Note: for now, try to keep the key and value as short as possible, Steam enforce a character limit on server tags, so it could be possible to reach that limit when running a Dedicated Server. In the future we'll store this stuff on our backend, so that won't be a problem.

ParameterTypeDescription
keystring
valuestring
Returns:void

public static System.Threading.Tasks.Task`1<bool> TryConnectSteamId(Sandbox.SteamId steamId, int retries = 30)PUBLICSTATIC

ParameterTypeDescription
steamIdSteamId
retries = 30int
Returns:Task<bool>

Properties10

Showing 10 properties

public static System.Collections.Generic.IReadOnlyList`1<Sandbox.Connection> Sandbox.Networking.Connections { get; set; }PUBLICSTATICGETSETOBSOLETE

A list of connections that are currently on this server. If you're not on a server this will return only one connection (Connection.Local). Some games restrict the connection list - in which case you will get an empty list.

Obsolete: Moved to Connection.All

Returns:IReadOnlyList<Connection>

public static Sandbox.Connection Sandbox.Networking.HostConnection { get; set; }PUBLICSTATICGETSETOBSOLETE

The connection of the current network host.

Obsolete: Moved to Connection.Host

Returns:Connection

public static Sandbox.Network.HostStats Sandbox.Networking.HostStats { get; set; }PUBLICSTATICGETSET

Get the latest host stats such as bandwidth used and the current frame rate.

Returns:HostStats

public static bool Sandbox.Networking.IsActive { get; set; }PUBLICSTATICGETSET

True if we're currently connecting to the server

Returns:bool

public static bool Sandbox.Networking.IsClient { get; set; }PUBLICSTATICGETSET

True if we're currently connected to a server, and we are not the host

Returns:bool

public static bool Sandbox.Networking.IsConnecting { get; set; }PUBLICSTATICGETSET

True if we're currently connecting to the server

Returns:bool

public static bool Sandbox.Networking.IsHost { get; set; }PUBLICSTATICGETSET

True if we can be considered the host of this session. Either we're not connected to a server, or we are host of a server.

Returns:bool

public static string Sandbox.Networking.MapName { get; set; }PUBLICSTATICGETSET

The name of the map being used on the server you're connected to.

Returns:string

public static int Sandbox.Networking.MaxPlayers { get; set; }PUBLICSTATICGETSET

The maximum number of players allowed on the server you're connected to.

Returns:int

public static string Sandbox.Networking.ServerName { get; set; }PUBLICSTATICGETSET

The name of the server you are currently connected to.

Returns:string

On this page

Methodspublic static System.Void Connect(System.String target)public static System.Void Connect(System.UInt64 steamid)public static System.Void CreateLobby()public static System.Void CreateLobby(Sandbox.Network.LobbyConfig config)public static System.Void Disconnect()public static Sandbox.Connection FindConnection(System.Guid id)public static System.String GetData(System.String key, System.String defaultValue)public static System.Threading.Tasks.Task`1<System.Boolean> JoinBestLobby(System.String ident)public static System.Threading.Tasks.Task`1<System.Collections.Generic.List`1<Sandbox.Network.LobbyInformation>> QueryLobbies(System.Collections.Generic.Dictionary`2<System.String,System.String> filters, System.Boolean includeServers = True, System.Threading.CancellationToken ct = null)public static System.Threading.Tasks.Task`1<System.Collections.Generic.List`1<Sandbox.Network.LobbyInformation>> QueryLobbies(System.String gameIdent, System.String mapIdent, System.Threading.CancellationToken ct = null)public static System.Threading.Tasks.Task`1<System.Collections.Generic.List`1<Sandbox.Network.LobbyInformation>> QueryLobbies(System.String gameIdent, System.Threading.CancellationToken ct = null)public static System.Threading.Tasks.Task`1<System.Collections.Generic.List`1<Sandbox.Network.LobbyInformation>> QueryLobbies(System.Threading.CancellationToken ct = null)public static System.Void SetData(System.String key, System.String value)public static System.Threading.Tasks.Task`1<System.Boolean> TryConnectSteamId(Sandbox.SteamId steamId, System.Int32 retries = 30)Propertiespublic static System.Collections.Generic.IReadOnlyList`1<Sandbox.Connection> Sandbox.Networking.Connections { get; set; }public static Sandbox.Connection Sandbox.Networking.HostConnection { get; set; }public static Sandbox.Network.HostStats Sandbox.Networking.HostStats { get; set; }public static System.Boolean Sandbox.Networking.IsActive { get; set; }public static System.Boolean Sandbox.Networking.IsClient { get; set; }public static System.Boolean Sandbox.Networking.IsConnecting { get; set; }public static System.Boolean Sandbox.Networking.IsHost { get; set; }public static System.String Sandbox.Networking.MapName { get; set; }public static System.Int32 Sandbox.Networking.MaxPlayers { get; set; }public static System.String Sandbox.Networking.ServerName { get; set; }Metadata