1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2026-06-09 23:56:48 +02:00
Files
Vitaly the Alpaca (bot) f0e7422301 Main build (Jenkins)
2026-04-29 16:58:20 +03:00

89 lines
2.5 KiB
Plaintext
Vendored

---
sidebar_position: 5
sidebar_class_name: doc-no-cli
description: Send data and other functions to work with TCP 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, TCP]
---
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"
LaunchPort = 9877;
ServerObject = OPI_TCP.StartServer(LaunchPort);
// Connect to running server
ConnectionAddress = "127.0.0.1:9877";
ClientObject = OPI_TCP.CreateConnection(ConnectionAddress);
If Not OPI_TCP.IsClientObject(ClientObject) Then
Raise OPI_Tools.JSONString(ClientObject);
EndIf;
Message = "Hello!" + Chars.LF;
OPI_TCP.SendLine(ClientObject, Message);
// Receive message and connection ID
NextMessage = OPI_TCP.GetNextConnectionData(ServerObject, 5000);
ConnectionID = NextMessage["connectionId"];
// Send response from server
ServerResponse = "Response from server!" + Chars.LF;
Result = OPI_TCP.SendData(ServerObject, ConnectionID, ServerResponse);
```
```json title="Result"
{
"result": true
}
```