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:44122",
"connectionId": "d62a3edd-d415-451a-8e44-05cce0e4df3b",
"isActive": true
},
{
"address": "127.0.0.1:44128",
"connectionId": "d2fb51be-c8eb-4a88-91c5-a3365ce1e732",
"isActive": true
}
],
"result": true
}