Send data
Sends data to the specified connection
- Parameters
- Advanced call ?
Function SendData(Val ServerObject, Val ConnectionID, Val Data) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| ServerObject | - | Arbitrary | ✔ | Object of running server component |
| ConnectionID | - | String | ✔ | Connection identifier |
| Data | - | String, BinaryData | ✔ | Sending data |
Returns
Map Of KeyAndValue - Execution result
This method has no additional advanced call parameters.
tip
Parameters with Binary data type can also accept file paths on disk and URLs
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 the next connection on the server and returning a response
NextMessage = OPI_WebSocket.GetNextConnectionData(ServerObject, 5000);
ConnectionID = NextMessage["connectionId"];
ServerResponse = "Response from server!";
Result = OPI_WebSocket.SendData(ServerObject, ConnectionID, ServerResponse);
Result
{
"result": true
}