1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2026-05-16 09:38:28 +02:00
Files
OpenIntegrations/docs/en/md/WebSocket/Server-methods/Send-data.mdx
T
Vitaly the Alpaca (bot) 456f2837fa Main build (Jenkins)
2026-05-02 23:28:47 +03:00

89 lines
2.6 KiB
Plaintext
Vendored

---
sidebar_position: 5
sidebar_class_name: doc-no-cli
description: Send data and other functions to work with WebSocket in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, WebSocket]
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Admonition from '@theme/Admonition';
# Send data
Sends data to the specified connection
<Tabs>
<TabItem value="params" label="Parameters" default>
`Function SendData(Val ServerObject, Val ConnectionID, Val Data) Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| ServerObject | - | Arbitrary | &#x2714; | Object of running server component |
| ConnectionID | - | String | &#x2714; | Connection identifier |
| Data | - | String, BinaryData | &#x2714; | Sending data |
<div className="return-value-note">
<div className="return-value-note__title">Returns</div>
<div className="return-value-note__value">
Map Of KeyAndValue - Execution result
</div>
</div>
</TabItem>
<TabItem value="extended" label={<span>Advanced call{' '}<a href="/docs/Start/Advanced-call" target="_blank" rel="noreferrer" title="About advanced call" onClick={(e) => e.stopPropagation()}>?</a></span>}>
*This method has no additional advanced call parameters.*
</TabItem>
</Tabs>
:::tip
Parameters with Binary data type can also accept file paths on disk and URLs
:::
<Admonition type="caution" title="Caution" className="nocli-admonition">
<div className="addin">
<strong>NOCLI:</strong> this method is not available in CLI version
</div>
</Admonition>
```bsl title="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);
```
```json title="Result"
{
"result": true
}
```