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.
Constructors1
Showing 1 constructors
public GameNetworkSystem()
No results match this filter.
Methods28
Showing 28 methods
public virtual bool AcceptConnection(Sandbox.Connection channel, string reason)
Called on the host to decide whether to accept a `Sandbox.Connection`.
| Parameter | Type | Description |
|---|---|---|
| channel | Connection | — |
| reason | string | The reason to display to the client. |
bool—public virtual System.Threading.Tasks.Task BecomeHostAsync(Sandbox.Connection previousHost, Sandbox.Network.SnapshotMsg snapshot)
We're already the host; load the previous host's snapshot.
| Parameter | Type | Description |
|---|---|---|
| previousHost | Connection | — |
| snapshot | SnapshotMsg | — |
Task—public void Broadcast(T obj, System.Nullable`1<Sandbox.Connection.Filter> filter = null)
| Parameter | Type | Description |
|---|---|---|
| obj | T | — |
| filter = null | Nullable<Filter> | — |
void—public void BroadcastRaw(Sandbox.ByteStream msg, System.Nullable`1<Sandbox.Connection.Filter> filter = null)
| Parameter | Type | Description |
|---|---|---|
| msg | ByteStream | — |
| filter = null | Nullable<Filter> | — |
void—public static void CreateLobby()
Obsolete: Moved to Networking.CreateLobby
void—public static void Disconnect()
Obsolete: Moved to Networking.Disconnect
void—public virtual void Dispose()
void—public virtual void GetMountedVPKs(Sandbox.Connection source, Sandbox.Network.MountedVPKsResponse msg)
| Parameter | Type | Description |
|---|---|---|
| source | Connection | — |
| msg | MountedVPKsResponse | — |
void—public virtual void GetSnapshot(Sandbox.Connection source, Sandbox.Network.SnapshotMsg msg)
| Parameter | Type | Description |
|---|---|---|
| source | Connection | — |
| msg | SnapshotMsg | — |
void—public virtual System.Threading.Tasks.Task MountVPKs(Sandbox.Connection source, Sandbox.Network.MountedVPKsResponse msg)
| Parameter | Type | Description |
|---|---|---|
| source | Connection | — |
| msg | MountedVPKsResponse | — |
Task—public virtual void OnBecameHost(Sandbox.Connection previousHost)
Legacy host-change callback. Override BecomeHostAsync to apply the handoff snapshot. The default BecomeHostAsync implementation calls this for existing subclasses.
| Parameter | Type | Description |
|---|---|---|
| previousHost | Connection | — |
void—public virtual void OnConnected(Sandbox.Connection client)
A client has connected to the server but hasn't fully finished joining yet.
| Parameter | Type | Description |
|---|---|---|
| client | Connection | — |
void—public virtual void OnHostChanged(Sandbox.Connection previousHost, Sandbox.Connection newHost)
Legacy host-change callback. Override ResyncFromHostAsync to apply the new host's snapshot. The default ResyncFromHostAsync implementation calls this for existing subclasses.
| Parameter | Type | Description |
|---|---|---|
| previousHost | Connection | — |
| newHost | Connection | — |
void—public virtual void OnInitialize()
Called when the network system should handle initialization.
void—public virtual void OnJoined(Sandbox.Connection client)
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.
| Parameter | Type | Description |
|---|---|---|
| client | Connection | — |
void—public virtual void OnLeave(Sandbox.Connection client)
A client has disconnected from the server.
| Parameter | Type | Description |
|---|---|---|
| client | Connection | — |
void—public virtual System.IDisposable Push()
Allows to push some kind of scope when reading network messages. This is useful if you need to adjust Time.Now etc.
IDisposable—public static System.Threading.Tasks.Task`1<System.Collections.Generic.List`1<Sandbox.Network.LobbyInformation>> QueryLobbies()
Obsolete: Moved to Networking.QueryLobbies
public virtual System.Threading.Tasks.Task ResyncFromHostAsync(Sandbox.Connection previousHost, Sandbox.Connection newHost, Sandbox.Network.SnapshotMsg snapshot)
Rebuild the game from the new host's snapshot.
| Parameter | Type | Description |
|---|---|---|
| previousHost | Connection | — |
| newHost | Connection | — |
| snapshot | SnapshotMsg | — |
Task—public void Send(System.Guid connectionId, T obj)
| Parameter | Type | Description |
|---|---|---|
| connectionId | Guid | — |
| obj | T | — |
void—public virtual System.Threading.Tasks.Task SetSnapshotAsync(Sandbox.Network.SnapshotMsg data)
| Parameter | Type | Description |
|---|---|---|
| data | SnapshotMsg | — |
Task—protected virtual void Tick()
Called every frame
void—public static System.Threading.Tasks.Task`1<bool> TryConnectSteamId(ulong steamId)
Obsolete: Moved to Networking.Connect
| Parameter | Type | Description |
|---|---|---|
| steamId | ulong | — |
Task<bool>—No results match this filter.
Properties4
Showing 4 properties
public static bool Sandbox.Network.GameNetworkSystem.IsActive { get; set; }
True if we're currently connected etc
Obsolete: Moved to Networking.IsActive
bool—public static bool Sandbox.Network.GameNetworkSystem.IsClient { get; set; }
True if we're connected to a server and not the host.
Obsolete: Moved to Networking.IsClient
bool—public static bool Sandbox.Network.GameNetworkSystem.IsConnecting { get; set; }
True if we're currently connecting to the server
Obsolete: Moved to Networking.IsConnecting
bool—public static bool Sandbox.Network.GameNetworkSystem.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 and we are the host.
Obsolete: Moved to Networking.IsHost
bool—No results match this filter.