Skip to main content

Process bidirectional stream

Initializes a bidirectional stream, then passes and sends messages in the specified order

Function ProcessBidirectionalStream(Val Connection, Val Service, Val Method, Val ExchangeOrder, Val Timeout = 10000, Val Tls = Undefined, Val ContinueReceiving = True) Export

ParameterCLI optionTypeRequiredDescription
Connection--connArbitraryExisting connection or connection parameters
Service--serviceStringService name
Method--methodStringMethod name
ExchangeOrder--exchArray Of ArbitraryArray of request data and Undefined where retrieval is needed
Timeout--toutNumberTimeout for individual operation (in ms))
Tls--tlsStructure Of KeyAndValueTLS settings, if necessary. See GetTlsSettings
ContinueReceiving--cntBooleanContinue receiving after processing the exchange order

Returns: Map Of KeyAndValue - Processing result

tip

Example: Retrieving a message after every two sent messages and three more at the end (null in 1C = Undefined))
ExchangeOrder: [{Message1}, {Message2}, null, {Message3}, ... {MessageN}, null, null, null, null, null]


1C:Enterprise/OneScript code example
    Address = "https://grpcb.in:9001";

Proto1 = "https://hut.openintegrations.dev/test_data/grpcbin_with_import.proto"; // String, path to file or URL
Proto2 = "https://hut.openintegrations.dev/test_data/mt.proto"; // String, path to file or URL

Scheme = New Map;
Scheme.Insert("main.proto" , Proto1); // Primary
Scheme.Insert("my_types.proto", Proto2); // For import in primary

Parameters = OPI_GRPC.GetConnectionParameters(Address, Scheme);
Tls = OPI_GRPC.GetTlsSettings(True);

StingsArray = New Array;
StingsArray.Add("one");
StingsArray.Add("two");
StingsArray.Add("three");

Data = New Map;
Data.Insert("f_string" , "Test message");
Data.Insert("f_bool" , True);
Data.Insert("f_strings", StingsArray);
Data.Insert("f_sub" , New Structure("f_string", "Nested value"));

Service = "grpcbin.GRPCBin";
Method = "DummyBidirectionalStreamStream";

ExchangeOrder = New Array;

For N = 1 To 10 Do

ExchangeOrder.Add(Data); // Single send
ExchangeOrder.Add(Undefined); // Single get

EndDo;

Result = OPI_GRPC.ProcessBidirectionalStream(Parameters, Service, Method, ExchangeOrder, , Tls);
    # JSON data can also be passed as a path to a .json file

oint grpc ProcessBidirectionalStream \
--conn "{'address':'https://grpcb.in:9001','proto':{'main.proto':'https://hut.openintegrations.dev/test_data/grpcbin_with_import.proto','my_types.proto':'https://hut.openintegrations.dev/test_data/mt.proto'}}" \
--service "grpcbin.GRPCBin" \
--method "DummyBidirectionalStreamStream" \
--exch "[{'f_string':'Test message','f_bool':true,'f_strings':['one','two','three'],'f_sub':{'f_string':'Nested value'}},null,{'f_string':'Test message','f_bool':true,'f_strings':['one','two','three'],'f_sub':{'f_string':'Nested value'}},null,{'f_string':'Test message','f_bool':true,'f_strings':['one','two','three'],'f_sub':{'f_string':'Nested value'}},null,{'f_string':'Test message','f_bool':true,'f_strings':['one','two','three'],'f_sub':{'f_string':'Nested value'}},null,{'f_string':'Test message','f_bool':true,'f_strings':['one','two','three'],'f_sub':{'f_string':'Nested value'}},null,{'f_string':'Test message','f_bool':true,'f_strings':['one','two','three'],'f_sub':{'f_string':'Nested value'}},null,{'f_string':'Test message','f_bool':true,'f_strings':['one','two','three'],'f_sub':{'f_string':'Nested value'}},null,{'f_string':'Test message','f_bool':true,'f_strings':['one','two','three'],'f_sub':{'f_string':'Nested value'}},null,{'f_string':'Test message','f_bool':true,'f_strings':['one','two','three'],'f_sub':{'f_string':'Nested value'}},null,{'f_string':'Test message','f_bool':true,'f_strings':['one','two','three'],'f_sub':{'f_string':'Nested value'}},null]" \
--tls "{'use_tls':true,'accept_invalid_certs':true}"
Result
{
"result": true,
"finish_sending": {
"result": true
},
"final_retrieval": {
"error": "Closed",
"result": false
},
"data": [
{
"f_bool": true,
"f_bools": [],
"f_bytes": {
"BYTES": ""
},
"f_bytess": [],
"f_enum": "ENUM_0",
"f_enums": [],
"f_float": 0,
"f_floats": [],
"f_int32": 0,
"f_int32s": [],
"f_int64": 0,
"f_int64s": [],
"f_string": "Test message",
"f_strings": [
"one",
"two",
"three"
],
"f_sub": {
"f_string": "Nested value"
},
"f_subs": []
},
{
"f_bool": true,
"f_bools": [],
"f_bytes": {
"BYTES": ""
},
"f_bytess": [],
"f_enum": "ENUM_0",
"f_enums": [],
"f_float": 0,
"f_floats": [],
"f_int32": 0,
"f_int32s": [],
"f_int64": 0,
"f_int64s": [],
"f_string": "Test message",
"f_strings": [
"one",
"two",
"three"
],
"f_sub": {
"f_string": "Nested value"
},
"f_subs": []
},
{
"f_bool": true,
"f_bools": [],
"f_bytes": {
"BYTES": ""
},
"f_bytess": [],
"f_enum": "ENUM_0",
"f_enums": [],
"f_float": 0,
"f_floats": [],
"f_int32": 0,
"f_int32s": [],
"f_int64": 0,
"f_int64s": [],
"f_string": "Test message",
"f_strings": [
"one",
"two",
"three"
],
"f_sub": {
"f_string": "Nested value"
},
"f_subs": []
},
{
"f_bool": true,
"f_bools": [],
"f_bytes": {
"BYTES": ""
},
"f_bytess": [],
"f_enum": "ENUM_0",
"f_enums": [],
"f_float": 0,
"f_floats": [],
"f_int32": 0,
"f_int32s": [],
"f_int64": 0,
"f_int64s": [],
"f_string": "Test message",
"f_strings": [
"one",
"two",
"three"
],
"f_sub": {
"f_string": "Nested value"
},
"f_subs": []
},
{
"f_bool": true,
"f_bools": [],
"f_bytes": {
"BYTES": ""
},
"f_bytess": [],
"f_enum": "ENUM_0",
"f_enums": [],
"f_float": 0,
"f_floats": [],
"f_int32": 0,
"f_int32s": [],
"f_int64": 0,
"f_int64s": [],
"f_string": "Test message",
"f_strings": [
"one",
"two",
"three"
],
"f_sub": {
"f_string": "Nested value"
},
"f_subs": []
},
{
"f_bool": true,
"f_bools": [],
"f_bytes": {
"BYTES": ""
},
"f_bytess": [],
"f_enum": "ENUM_0",
"f_enums": [],
"f_float": 0,
...