codeAPI Reference

Connection API: Properties, Methods, and Common Multiplayer Patterns

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50

The Connection class represents a network connection (client or server). Used extensively in multiplayer for identifying players, checking permissions, and managing network state.

Key Properties

CSHARP
Connection connection = ...;

connection.Id            // Guid — unique identifier
connection.DisplayName   // string — player's display name
connection.SteamId       // SteamId — Steam 64-bit ID
connection.IsHost        // bool — is this the host connection
connection.IsActive      // bool — fully connected and logged on
connection.IsConnecting  // bool — still in handshake
connection.Ping          // float — latency in milliseconds
connection.PartyId       // SteamId — party group ID for team matching

// Permissions
connection.CanSpawnObjects    // bool — can create networked objects
connection.CanRefreshObjects  // bool — can refresh owned objects
connection.CanDestroyObjects  // bool — can destroy owned objects

Static Members

CSHARP
Connection.Local  // "Fake" connection for the local player
Connection.Host   // The current network host's connection
Connection.All    // IReadOnlyList<Connection> of all connected clients
Connection.Find( guid )  // Find connection by ID

Methods

CSHARP
connection.Kick( "reason" );                    // Host-only: kick client
connection.HasPermission( "admin" );            // Check permission
connection.SendMessage( myMessage );            // Send typed message
connection.Down( "attack1" );                   // Check if action is held
connection.Pressed( "jump" );                   // Check if action pressed this frame
connection.HasInventoryItem( definitionId );    // Check Steam inventory
await connection.SendRequest( request );        // Send and await response

Common Patterns

CSHARP
// In INetworkListener.OnActive
public void OnActive( Connection connection )
{
    connection.CanSpawnObjects = false;
    var player = PlayerPrefab.Clone( SpawnPoint.Transform.World );
    player.NetworkSpawn( connection );
}

// Finding a connection
var conn = Connection.Find( playerId );
if ( conn != null && conn.IsActive )
{
    conn.SendMessage( new ChatMessage { Text = "Hello!" } );
}
Was this helpful?