Connectionclass

A connection, usually to a server or a client.

objectConnection
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public abstract class Sandbox.Connection

Constructors1

Showing 1 constructors

Methods13

Showing 13 methods

public float DistanceSquared(Vector3 position)PUBLIC

Calculate the closest distance (squared) to a position based on the Pvs sources from this `Sandbox.Connection`.

ParameterTypeDescription
positionVector3
Returns:float

public bool Down(string action)PUBLIC

Action is currently pressed down for this `Sandbox.Connection`.

ParameterTypeDescription
actionstring
Returns:bool

public static Sandbox.Connection Find(System.Guid id)PUBLICSTATIC

Find a `Sandbox.Connection` for a Connection Id.

ParameterTypeDescription
idGuid
Returns:Connection

public string GetUserData(string key)PUBLIC

ParameterTypeDescription
keystring
Returns:string

public bool HasInventoryItem(int definitionId)PUBLIC

Check if this connection has a specific inventory item in their Steam Inventory

ParameterTypeDescription
definitionIdint
Returns:bool

public virtual bool HasPermission(string permission)PUBLICVIRTUAL

Get whether this connection has a specific permission.

ParameterTypeDescription
permissionstring
Returns:bool

public virtual void Kick(string reason)PUBLICVIRTUAL

Kick this `Sandbox.Connection` from the server. Only the host can kick clients.

ParameterTypeDescription
reasonstringThe reason to display to this client.
Returns:void

public bool Pressed(string action)PUBLIC

Action was pressed for this `Sandbox.Connection` within the current update context.

ParameterTypeDescription
actionstring
Returns:bool

public bool Released(string action)PUBLIC

Action was released for this `Sandbox.Connection` within the current update context.

ParameterTypeDescription
actionstring
Returns:bool

public void SendLog(Sandbox.LogLevel level, string message)PUBLIC

Log a message to the console for this connection.

ParameterTypeDescription
levelLogLevel
messagestring
Returns:void

public void SendMessage(T t)PUBLIC

Send a message to this connection.

ParameterTypeDescription
tT
Returns:void

public System.Threading.Tasks.Task`1<object> SendRequest(T t)PUBLIC

Send a message to this connection, wait for a response

ParameterTypeDescription
tT
Returns:Task<object>

public void SendResponse(System.Guid requestId, T t)PUBLIC

Send a response message to this connection.

ParameterTypeDescription
requestIdGuid
tT
Returns:void

Properties24

Showing 24 properties

public virtual string Sandbox.Connection.Address { get; set; }PUBLICVIRTUALGETSET

Returns:string

public static System.Collections.Generic.IReadOnlyList`1<Sandbox.Connection> Sandbox.Connection.All { get; set; }PUBLICSTATICGETSET

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.

Returns:IReadOnlyList<Connection>

public bool Sandbox.Connection.CanDestroyObjects { get; set; }PUBLICGETSET

Can this connection destroy networked objects they own?

Returns:bool

public bool Sandbox.Connection.CanRefreshObjects { get; set; }PUBLICGETSET

Can this connection refresh networked objects that they own?

Returns:bool

public bool Sandbox.Connection.CanSpawnObjects { get; set; }PUBLICGETSET

Can this connection spawn networked objects?

Returns:bool

public System.DateTimeOffset Sandbox.Connection.ConnectionTime { get; set; }PUBLICGETSET

Returns:DateTimeOffset

public string Sandbox.Connection.DisplayName { get; set; }PUBLICGETSET

The player's name but with any potential nicknames or naughty words filtered out. You don't want to be using this in serverside logic really.

Returns:string

public Sandbox.Friend Sandbox.Connection.FriendInfo { get; set; }PUBLICGETSET

Steam friend information for this connection. This is not available on the dedicated server.

Returns:Friend

public static Sandbox.Connection Sandbox.Connection.Host { get; set; }PUBLICSTATICGETSET

The connection of the current network host.

Returns:Connection

public System.Guid Sandbox.Connection.Id { get; set; }PUBLICGETSET

This connection's unique identifier.

Returns:Guid

public bool Sandbox.Connection.IsActive { get; set; }PUBLICGETSET

True if this channel is fully connnected and fully logged on.

Returns:bool

public bool Sandbox.Connection.IsConnecting { get; set; }PUBLICGETSET

True if this channel is still currently connecting.

Returns:bool

public virtual bool Sandbox.Connection.IsHost { get; set; }PUBLICVIRTUALGETSET

Returns:bool

public virtual float Sandbox.Connection.Latency { get; set; }PUBLICVIRTUALGETSET

Returns:float

public static Sandbox.Connection Sandbox.Connection.Local { get; set; }PUBLICSTATICGETSET

This is a "fake" connection for the local player. It is passed to RPCs when calling them locally etc.

Returns:Connection

public int Sandbox.Connection.MessagesRecieved { get; set; }PUBLICGETSET

How many messages have been received from this connection?

Returns:int

public int Sandbox.Connection.MessagesSent { get; set; }PUBLICGETSET

How many messages have been sent to this connection?

Returns:int

public string Sandbox.Connection.Name { get; set; }PUBLICGETSET

The player's name.

Returns:string

public Sandbox.SteamId Sandbox.Connection.OwnerSteamId { get; set; }PUBLICGETSET

The SteamID of the account that actually owns the game in a Steam Family. If not in a Steam Family this is the same as `Sandbox.Connection.SteamId`

Note

This is only valid on the host.

Returns:SteamId

public Sandbox.SteamId Sandbox.Connection.PartyId { get; set; }PUBLICGETSET

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.

Returns:SteamId

public float Sandbox.Connection.Ping { get; set; }PUBLICGETSET

The ping of this connection (in milliseconds.)

Returns:float

public virtual float Sandbox.Connection.Time { get; set; }PUBLICVIRTUALGETSET

Returns:float

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 Sandbox.Friend Sandbox.Connection.FriendInfo { 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 System.String Sandbox.Connection.Name { get; set; }public Sandbox.SteamId Sandbox.Connection.OwnerSteamId { 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