public abstract class Sandbox.Connection
A connection, usually to a server or a client.
Related Guides
Broader workflow and conceptual references connected to this API.
On a Dedicated Server, you can specify who is an admin of your server, or customize permissions even further with claims for individual Steam accounts.
The host can change some permissions for a specific Connection. The ideal place to set these permissions would be in the OnActive network event.
You can create variables and commands that you can run from the console.
Allows a GameObject's Components to listen to changes in ownership state.
Your games will likely want to react to people joining and leaving the game. To help with this you can implement Component.INetworkListener or Component.INetworkSpawn on a component and place it in the scene.
Network Visibility controls whether a networked object should be visible for a specific player (Connection). Visibility determines whether the object receives ongoing network updates — such as Sync Vars and Transform updates — for that client.
Constructors
Showing 1 constructors
protected Connection()
No results match this filter.
Methods
Showing 13 methods
public float DistanceSquared(Vector3 position)
Calculate the closest distance (squared) to a position based on the Pvs sources from this `Sandbox.Connection`.
public bool Down(string action)
Action is currently pressed down for this `Sandbox.Connection`.
public static Sandbox.Connection Find(System.Guid id)
Find a `Sandbox.Connection` for a Connection Id.
public string GetUserData(string key)
public bool HasInventoryItem(int definitionId)
Check if this connection has a specific inventory item in their Steam Inventory
public virtual bool HasPermission(string permission)
Get whether this connection has a specific permission.
public virtual void Kick(string reason)
Kick this `Sandbox.Connection` from the server. Only the host can kick clients.
Parameters
reason: The reason to display to this client.
public bool Pressed(string action)
Action was pressed for this `Sandbox.Connection` within the current update context.
public bool Released(string action)
Action was released for this `Sandbox.Connection` within the current update context.
public void SendLog(Sandbox.LogLevel level, string message)
Log a message to the console for this connection.
public void SendMessage(T t)
Send a message to this connection.
public System.Threading.Tasks.Task`1<object> SendRequest(T t)
Send a message to this connection, wait for a response
public void SendResponse(System.Guid requestId, T t)
Send a response message to this connection.
No results match this filter.
Properties
Showing 22 properties
public virtual string Sandbox.Connection.Address { get; set; }
public static System.Collections.Generic.IReadOnlyList`1<Sandbox.Connection> Sandbox.Connection.All { get; set; }
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.
public bool Sandbox.Connection.CanDestroyObjects { get; set; }
Can this connection destroy networked objects they own?
public bool Sandbox.Connection.CanRefreshObjects { get; set; }
Can this connection refresh networked objects that they own?
public bool Sandbox.Connection.CanSpawnObjects { get; set; }
Can this connection spawn networked objects?
public System.DateTimeOffset Sandbox.Connection.ConnectionTime { get; set; }
public string Sandbox.Connection.DisplayName { get; set; }
public static Sandbox.Connection Sandbox.Connection.Host { get; set; }
The connection of the current network host.
public System.Guid Sandbox.Connection.Id { get; set; }
This connection's unique identifier.
public bool Sandbox.Connection.IsActive { get; set; }
True if this channel is fully connnected and fully logged on.
public bool Sandbox.Connection.IsConnecting { get; set; }
True if this channel is still currently connecting.
public virtual bool Sandbox.Connection.IsHost { get; set; }
public virtual float Sandbox.Connection.Latency { get; set; }
public static Sandbox.Connection Sandbox.Connection.Local { get; set; }
This is a "fake" connection for the local player. It is passed to RPCs when calling them locally etc.
public int Sandbox.Connection.MessagesRecieved { get; set; }
How many messages have been received from this connection?
public int Sandbox.Connection.MessagesSent { get; set; }
How many messages have been sent to this connection?
public virtual string Sandbox.Connection.Name { get; set; }
public Sandbox.SteamId Sandbox.Connection.PartyId { get; set; }
The Id of the party that this user is a part of. This can be used to compare to other users to group them into parties.
public float Sandbox.Connection.Ping { get; set; }
The ping of this connection (in milliseconds.)
public virtual Sandbox.Network.ConnectionStats Sandbox.Connection.Stats { get; set; }
Get stats about this connection such as bandwidth usage and how many packets are being sent and received.
public Sandbox.SteamId Sandbox.Connection.SteamId { get; set; }
public virtual float Sandbox.Connection.Time { get; set; }
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.Connection |