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
LaunchPort = 9877;
ServerObject = OPI_TCP.StartServer(LaunchPort);

// Connect to running server
ConnectionAddress = "127.0.0.1:9877";

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

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

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

Result = OPI_TCP.GetConnectionList(ServerObject);
Result
{
"connections": [
{
"address": "127.0.0.1:56006",
"canRead": true,
"canWrite": true,
"connectionId": "d658fe87-b7d2-48c2-bfb9-547dda0dc5b5"
},
{
"address": "127.0.0.1:56020",
"canRead": true,
"canWrite": true,
"connectionId": "d4768bed-f249-405f-905a-e7a4c055239f"
}
],
"result": true
}