Skip to main content

Get next connection data

Gets data from the buffer of the next active connection in the queue where there are incoming data

Function GetNextConnectionData(Val ServerObject, Val Timeout = 1000, Val MaxSize = 8192) Export

ParameterCLI optionTypeRequiredDescription
ServerObject-ArbitraryObject of running server component
Timeout-NumberWaiting period for new data if the queue is empty (in ms)
MaxSize-NumberMaximum size of data to receive
Returns

Map Of KeyAndValue - Execution result

Caution

NOCLI: this method is not available in CLI version

1C:Enterprise/OneScript code example
LaunchPort = 9877;
ServerObject = OPI_TCP.StartServer(LaunchPort);

// Send message from client
ConnectionAddress = "127.0.0.1:9877";
ClientObject = OPI_TCP.CreateConnection(ConnectionAddress);

If Not OPI_TCP.IsClientObject(ClientObject) Then
Raise OPI_Tools.JSONString(ClientObject);
Else
Message = "Hello from client!" + Chars.LF;
OPI_TCP.SendLine(ClientObject, Message);
EndIf;

// Receive message on server
Result = OPI_TCP.GetNextConnectionData(ServerObject, 5000, 8192);
Result
{
"active": true,
"address": "127.0.0.1:49398",
"connectionId": "1f0461ee-11ea-4a7f-8d2f-430c323a5984",
"message": "<BinaryData>",
"result": true
}