Networking
public static abstract sealed class Networking Global manager to hold and tick the singleton instance of NetworkSystem.
Properties
| Name | Type | Description |
|---|---|---|
ServerName static | String | The name of the server you are currently connected to. |
MapName static | String | The name of the map being used on the server you're connected to. |
MaxPlayers static | Int32 | The maximum number of players allowed on the server you're connected to. |
HostStats static | HostStats | Get the latest host stats such as bandwidth used and the current frame rate. |
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 host of a server. |
IsClient static | Boolean | True if we're currently connected to a server, and we are not the host |
IsConnecting static | Boolean | True if we're currently connecting to the server |
IsActive static | Boolean | True if we're currently connecting to the server |
HostConnection static | Connection | The connection of the current network host. |
Connections static | IReadOnlyList<Connection> | 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. |
Methods
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.
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.
static Connection FindConnection(Guid id) static Task<Boolean> JoinBestLobby(String ident) Try to join the best lobby. Return true on success.
static Void CreateLobby(LobbyConfig config) Will create a new lobby with the specified LobbyConfig to customize the lobby further.
static Void CreateLobby() Will create a new lobby.
static Void Disconnect() Disconnect from current multiplayer session.
static Void Connect(UInt64 steamid) static Void Connect(String target) Will try to determine the right method for connection, and then try to connect.
static Task<Boolean> TryConnectSteamId(SteamId steamId) Will try to connect to a server. Will return false if failed to connect.
static List<LobbyInformation>> QueryLobbies(CancellationToken ct = null) Get all lobbies for the current game.
static List<LobbyInformation>> QueryLobbies(String gameIdent, CancellationToken ct = null) Get all lobbies for a specific game.
static List<LobbyInformation>> QueryLobbies(String gameIdent, String mapIdent, CancellationToken ct = null) Get all lobbies for a specific game and map.
static List<LobbyInformation>> QueryLobbies(Dictionary<String, String> filters, Boolean includeServers = True, CancellationToken ct = null)