s&box docs

public static abstract sealed class Sandbox.Networking

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

Broader workflow and conceptual references connected to this API.

Methods

Showing 14 methods

public static void Disconnect()

Disconnect from current multiplayer session.

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

Obsolete: Moved to Connection.Find

public static string GetData(string key, string defaultValue)

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

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

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

public static void SetData(string key, string value)

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.

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

Parameters

  • retries: Default: 30

Properties

Showing 10 properties

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

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

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

The connection of the current network host.

Obsolete: Moved to Connection.Host

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

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

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

True if we're currently connecting to the server

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

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

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

True if we're currently connecting to the server

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

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.

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

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

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

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

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

The name of the server you are currently connected to.

Metadata

FieldValue
NamespaceSandbox
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.Networking

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