Close incoming connection
Closes incoming server connection by ID
- Parameters
- Advanced call ?
Function CloseIncomingConnection(Val ServerObject, Val ConnectionID, Val RemoveImmediately = True) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| ServerObject | - | Arbitrary | ✔ | Object of running server component |
| ConnectionID | - | String | ✔ | Connection identifier |
| RemoveImmediately | - | Boolean | ✖ | If True, the connection will be removed from the list immediately |
Returns
Map Of KeyAndValue - Execution result
This method has no additional advanced call parameters.
Caution
NOCLI: this method is not available in CLI version
1C:Enterprise/OneScript code example
// Server start
LaunchPort = 9894;
ServerObject = OPI_WebSocket.StartServer(LaunchPort);
// Client connect to server
ConnectionAddress = "ws://127.0.0.1:9894";
ClientObject = OPI_WebSocket.CreateConnection(ConnectionAddress);
If Not OPI_WebSocket.IsClientObject(ClientObject) Then
Raise OPI_Tools.JSONString(ClientObject);
EndIf;
// Client message send
Message = "Hello!";
OPI_WebSocket.SendTextMessage(ClientObject, Message);
// Receiving and closing connection on the server
FirstMessage = OPI_WebSocket.GetNextConnectionData(ServerObject, 5000);
ConnectionID = FirstMessage["connectionId"];
Result = OPI_WebSocket.CloseIncomingConnection(ServerObject, ConnectionID, True);
Result
{
"message": "WebSocket closed",
"result": true
}