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/Client-methods/Get-message.mdx
T
Vitaly the Alpaca (bot) 456f2837fa Main build (Jenkins)
2026-05-02 23:28:47 +03:00

123 lines
3.1 KiB
Plaintext
Vendored

---
sidebar_position: 5
sidebar_class_name: doc-no-cli
description: Get message 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 message
Receives an incoming message from the queue or waits for a new one
<Tabs>
<TabItem value="params" label="Parameters" default>
`Function GetMessage(Val Connection, Val Timeout = 10000) Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Connection | - | Arbitrary | &#x2714; | Connection, See CreateConnection |
| Timeout | - | Number | &#x2716; | Message receive timeout (in ms.) |
<div className="return-value-note">
<div className="return-value-note__title">Returns</div>
<div className="return-value-note__value">
BinaryData - Received message
</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"
Address = "wss://127.0.0.1:8443";
NeedProxy = True;
NeedTLS = True;
Headers = New Map;
Headers.Insert("X-Trace-Id", "OPI-WS-TEST");
If NeedTls Then
TLSSettings = OPI_WebSocket.GetTlsSettings(True);
EndIf;
If NeedProxy Then
ProxyAddress = "127.0.0.1";
ProxyPort = "8071";
ProxyType = "http";
ProxtUser = "proxyuser";
ProxyPassword = "12we...";
ProxySettings = OPI_AddIns.GetProxySettings(ProxyAddress
, ProxyPort
, ProxyType
, ProxtUser
, ProxyPassword);
EndIf;
Connection = OPI_WebSocket.CreateConnection(Address, TLSSettings, ProxySettings, Headers);
Message = "echo-text-" + Format(CurrentDate(), "DF=yyyyMMddhhmmss");
If OPI_WebSocket.IsClientObject(Connection) Then
// Sending a message to the ECHO server
Sending = OPI_WebSocket.SendTextMessage(Connection, Message);
// Skipping all responses from the server until the last one
While True Do
LastMessage = OPI_WebSocket.GetMessage(Connection, 3000); // <----
If LastMessage["result"] Then
Result = LastMessage;
Else
Break;
EndIf;
EndDo;
Else
Result = Connection;
EndIf;
```
```json title="Result"
{
"data": {
"type": "echo",
"payload": "echo-text-20260502110655",
"tls": true,
"timestamp": "2026-05-02T11:06:55.073Z"
},
"result": true,
"type": "text"
}
```