Skip to main content

Get connection list

Gets the list of connections

Function GetConnectionList(Val ServerObject) Export

ParameterCLI optionTypeRequiredDescription
ServerObject-ArbitraryObject of running server component
Returns

Map Of KeyAndValue - Execution result

tip

The list displays active connections and closed connections with unprocessed data in the buffer

Caution

NOCLI: this method is not available in CLI version

1C:Enterprise/OneScript code example
// Server start
LaunchPort = 9894;
ServerObject = OPI_WebSocket.StartServer(LaunchPort);

// Creating multiple client connections
ConnectionAddress = "ws://127.0.0.1:9894";

Client1 = OPI_WebSocket.CreateConnection(ConnectionAddress);
Client2 = OPI_WebSocket.CreateConnection(ConnectionAddress);

If Not OPI_WebSocket.IsClientObject(Client1) Then
Raise OPI_Tools.JSONString(Client1);
EndIf;

If Not OPI_WebSocket.IsClientObject(Client2) Then
Raise OPI_Tools.JSONString(Client2);
EndIf;

// Getting a list of active connections on the server
Result = OPI_WebSocket.GetConnectionList(ServerObject);
Result
{
"connections": [
{
"address": "127.0.0.1:63016",
"connectionId": "02fab32b-b1e2-4819-a46e-e29780c5c3fe",
"isActive": true
},
{
"address": "127.0.0.1:63017",
"connectionId": "d54be98a-ea60-4e69-bccc-dada02fd1577",
"isActive": true
}
],
"result": true
}