s&box docs

public abstract class Sandbox.Connection

A connection, usually to a server or a client.

Broader workflow and conceptual references connected to this API.

Constructors

Showing 1 constructors

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.

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.

Metadata

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

On this page

Constructorsprotected Connection()Methodspublic System.Single DistanceSquared(Vector3 position)public System.Boolean Down(System.String action)public static Sandbox.Connection Find(System.Guid id)public System.String GetUserData(System.String key)public System.Boolean HasInventoryItem(System.Int32 definitionId)public virtual System.Boolean HasPermission(System.String permission)public virtual System.Void Kick(System.String reason)public System.Boolean Pressed(System.String action)public System.Boolean Released(System.String action)public System.Void SendLog(Sandbox.LogLevel level, System.String message)public System.Void SendMessage(T t)public System.Threading.Tasks.Task`1<System.Object> SendRequest(T t)public System.Void SendResponse(System.Guid requestId, T t)Propertiespublic virtual System.String Sandbox.Connection.Address { get; set; }public static System.Collections.Generic.IReadOnlyList`1<Sandbox.Connection> Sandbox.Connection.All { get; set; }public System.Boolean Sandbox.Connection.CanDestroyObjects { get; set; }public System.Boolean Sandbox.Connection.CanRefreshObjects { get; set; }public System.Boolean Sandbox.Connection.CanSpawnObjects { get; set; }public System.DateTimeOffset Sandbox.Connection.ConnectionTime { get; set; }public System.String Sandbox.Connection.DisplayName { get; set; }public static Sandbox.Connection Sandbox.Connection.Host { get; set; }public System.Guid Sandbox.Connection.Id { get; set; }public System.Boolean Sandbox.Connection.IsActive { get; set; }public System.Boolean Sandbox.Connection.IsConnecting { get; set; }public virtual System.Boolean Sandbox.Connection.IsHost { get; set; }public virtual System.Single Sandbox.Connection.Latency { get; set; }public static Sandbox.Connection Sandbox.Connection.Local { get; set; }public System.Int32 Sandbox.Connection.MessagesRecieved { get; set; }public System.Int32 Sandbox.Connection.MessagesSent { get; set; }public virtual System.String Sandbox.Connection.Name { get; set; }public Sandbox.SteamId Sandbox.Connection.PartyId { get; set; }public System.Single Sandbox.Connection.Ping { get; set; }public virtual Sandbox.Network.ConnectionStats Sandbox.Connection.Stats { get; set; }public Sandbox.SteamId Sandbox.Connection.SteamId { get; set; }public virtual System.Single Sandbox.Connection.Time { get; set; }Metadata