Description
The All
property provides a list of all active connections currently on the server. This list includes all clients connected to the server. If the code is executed in a non-server environment, the list will contain only one connection, which is Connection.Local
. In some game scenarios, the connection list might be restricted, resulting in an empty list.
Usage
Use the All
property to access and iterate over all active connections on the server. This can be useful for server-side operations that need to interact with all connected clients, such as broadcasting messages or managing client states.
Example
// Example: Iterating over all connections and printing their names
foreach (var connection in Connection.All)
{
string connectionName = connection.Name;
// Perform operations with each connection
// For example, logging the connection name
// Log(connectionName);
}