public static abstract sealed class Sandbox.Networking
Global manager to hold and tick the singleton instance of NetworkSystem.
Related Guides
Broader workflow and conceptual references connected to this API.
This event interface allows you to listen to Scene startup events. These events are run in three places:
The networking system in s&box is purposefully simple and easy. Our initial aim isn't to provide a bullet proof server-authoritative networking system. Our aim is to provide a system that is really easy to use and understand.
If you are using HTTP requests or WebSockets in your game, you can use Auth Tokens to validate that the requests were sent from a valid Steam user in a s&box game session. This is useful if you want to tie data to a specific Steam account, or prevent botting.
There are various interfaces that can be given to components for specific purposes.
The host can change some permissions for a specific Connection. The ideal place to set these permissions would be in the OnActive network event.
S&box uses a scene system to create games. We feel this is the easiest system for people to pick up, while still being powerful.
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
No results match this filter.
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.
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.Networking |