Connection
public abstract class Connection A connection, usually to a server or a client.
Properties
| Name | Type | Description |
|---|---|---|
Id | Guid | This connection's unique identifier. |
CanSpawnObjects | Boolean | Can this connection spawn networked objects? |
CanRefreshObjects | Boolean | Can this connection refresh networked objects that they own? |
CanDestroyObjects | Boolean | Can this connection destroy networked objects they own? |
Latency virtual | Single | |
Name virtual | String | |
Time virtual | Single | |
Address virtual | String | |
IsHost virtual | Boolean | |
IsConnecting | Boolean | True if this channel is still currently connecting. |
IsActive | Boolean | True if this channel is fully connnected and fully logged on. |
MessagesSent | Int32 | How many messages have been sent to this connection? |
MessagesRecieved | Int32 | How many messages have been received from this connection? |
Stats virtual | ConnectionStats | Get stats about this connection such as bandwidth usage and how many packets are being sent and received. |
Ping | Single | The ping of this connection (in milliseconds.) |
DisplayName | String | |
SteamId | SteamId | |
PartyId | SteamId | 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. |
ConnectionTime | DateTimeOffset | |
Local static | Connection | This is a "fake" connection for the local player. It is passed to RPCs when calling them locally etc. |
All 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. |
Host static | Connection | The connection of the current network host. |
Methods
virtual Boolean HasPermission(String permission) Get whether this connection has a specific permission.
Single DistanceSquared(Vector3 position) Calculate the closest distance (squared) to a position based on the Pvs sources from this Connection.
virtual Void Kick(String reason) Kick this Connection from the server. Only the host can kick clients.
reason — The reason to display to this client. Void SendLog(LogLevel level, String message) Log a message to the console for this connection.
Void SendMessage(T t) Send a message to this connection.
String GetUserData(String key) Boolean HasInventoryItem(Int32 definitionId) Check if this connection has a specific inventory item in their Steam Inventory
Boolean Down(String action) Action is currently pressed down for this Connection.
Boolean Pressed(String action) Action was pressed for this Connection within the current update context.
Boolean Released(String action) Action was released for this Connection within the current update context.
Task<Object> SendRequest(T t) Send a message to this connection, wait for a response
Void SendResponse(Guid requestId, T t) Send a response message to this connection.
static Connection Find(Guid id) Find a Connection for a Connection Id.