You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2026-05-16 09:38:28 +02:00
103 lines
3.1 KiB
Plaintext
Vendored
103 lines
3.1 KiB
Plaintext
Vendored
---
|
|
sidebar_position: 4
|
|
sidebar_class_name: doc-no-cli
|
|
description: Get connection 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';
|
|
|
|
# Get connection data
|
|
Gets data from the buffer of a specific connection by ID
|
|
|
|
|
|
|
|
<Tabs>
|
|
<TabItem value="params" label="Parameters" default>
|
|
|
|
`Function GetConnectionData(Val ServerObject, Val ConnectionID, Val Timeout = 1000) Export`
|
|
|
|
| Parameter | CLI option | Type | Required | Description |
|
|
|-|-|-|-|-|
|
|
| ServerObject | - | Arbitrary | ✔ | Object of running server component |
|
|
| ConnectionID | - | String | ✔ | Connection identifier |
|
|
| Timeout | - | Number | ✖ | Waiting period for new data if the queue is empty (in ms) |
|
|
|
|
|
|
<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>
|
|
|
|
|
|
<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;
|
|
|
|
// Getting a list of active connections on the server
|
|
ConnectionList = OPI_WebSocket.GetConnectionList(ServerObject);
|
|
|
|
If Not ConnectionList["result"] Then
|
|
Raise OPI_Tools.JSONString(ConnectionList);
|
|
EndIf;
|
|
|
|
If ConnectionList["connections"].Count() = 0 Then
|
|
Raise "Connection list is empty";
|
|
Else
|
|
ConnectionID = ConnectionList["connections"][0]["connectionId"];
|
|
EndIf;
|
|
|
|
For N = 0 To 5 Do
|
|
|
|
// Client message send
|
|
CurrentMessage = StrTemplate("Message no. %1", N);
|
|
OPI_WebSocket.SendTextMessage(ClientObject, CurrentMessage);
|
|
|
|
// Receiving an incoming message on the server by ID
|
|
Result = OPI_WebSocket.GetConnectionData(ServerObject, ConnectionID, 5000);
|
|
|
|
EndDo;
|
|
```
|
|
|
|
|
|
|
|
|
|
```json title="Result"
|
|
{
|
|
"address": "127.0.0.1:49110",
|
|
"connectionId": "0fe70ce6-3f7a-4d69-9fbf-5ae2a288ca28",
|
|
"isActive": true,
|
|
"message": "<Binary data>",
|
|
"result": true
|
|
}
|
|
```
|