update
This commit is contained in:
@@ -159,8 +159,8 @@ println("Message sent!")
|
||||
from nats_bridge import smartreceive
|
||||
|
||||
# Receive and process message
|
||||
envelope = smartreceive(msg)
|
||||
for dataname, data, type in envelope["payloads"]:
|
||||
env = smartreceive(msg)
|
||||
for dataname, data, type in env["payloads"]:
|
||||
print(f"Received {dataname}: {data}")
|
||||
```
|
||||
|
||||
@@ -170,8 +170,8 @@ for dataname, data, type in envelope["payloads"]:
|
||||
const { smartreceive } = require('./src/NATSBridge');
|
||||
|
||||
// Receive and process message
|
||||
const envelope = await smartreceive(msg);
|
||||
for (const payload of envelope.payloads) {
|
||||
const env = await smartreceive(msg);
|
||||
for (const payload of env.payloads) {
|
||||
console.log(`Received ${payload.dataname}: ${payload.data}`);
|
||||
}
|
||||
```
|
||||
@@ -182,8 +182,8 @@ for (const payload of envelope.payloads) {
|
||||
using NATSBridge
|
||||
|
||||
# Receive and process message
|
||||
envelope = smartreceive(msg, fileserverDownloadHandler)
|
||||
for (dataname, data, type) in envelope["payloads"]
|
||||
env = smartreceive(msg, fileserverDownloadHandler)
|
||||
for (dataname, data, type) in env["payloads"]
|
||||
println("Received $dataname: $data")
|
||||
end
|
||||
```
|
||||
@@ -313,10 +313,10 @@ const { smartreceive, smartsend } = require('./src/NATSBridge');
|
||||
const sub = nc.subscribe("/device/command");
|
||||
|
||||
for await (const msg of sub) {
|
||||
const envelope = await smartreceive(msg);
|
||||
const env = await smartreceive(msg);
|
||||
|
||||
// Process command
|
||||
for (const payload of envelope.payloads) {
|
||||
for (const payload of env.payloads) {
|
||||
if (payload.dataname === "command") {
|
||||
const command = payload.data;
|
||||
|
||||
@@ -331,8 +331,8 @@ for await (const msg of sub) {
|
||||
await smartsend("/device/response", [
|
||||
{ dataname: "sensor_data", data: response, type: "dictionary" }
|
||||
], {
|
||||
reply_to: envelope.replyTo,
|
||||
reply_to_msg_id: envelope.msgId
|
||||
reply_to: env.replyTo,
|
||||
reply_to_msg_id: env.msgId
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -528,8 +528,8 @@ env, env_json_str = smartsend("/analysis/config", data, nats_url="nats://localho
|
||||
const { smartreceive } = require('./src/NATSBridge');
|
||||
|
||||
// Receive dictionary from Julia
|
||||
const envelope = await smartreceive(msg);
|
||||
for (const payload of envelope.payloads) {
|
||||
const env = await smartreceive(msg);
|
||||
for (const payload of env.payloads) {
|
||||
if (payload.type === "dictionary") {
|
||||
console.log("Received config:", payload.data);
|
||||
// payload.data = { step_size: 0.01, iterations: 1000 }
|
||||
@@ -554,8 +554,8 @@ const { env, env_json_str } = await smartsend("/data/transfer", [
|
||||
```python
|
||||
from nats_bridge import smartreceive
|
||||
|
||||
envelope = smartreceive(msg)
|
||||
for dataname, data, type in envelope["payloads"]:
|
||||
env = smartreceive(msg)
|
||||
for dataname, data, type in env["payloads"]:
|
||||
if type == "text":
|
||||
print(f"Received from JS: {data}")
|
||||
```
|
||||
@@ -576,8 +576,8 @@ env, env_json_str = smartsend("/chat/python", data)
|
||||
```julia
|
||||
using NATSBridge
|
||||
|
||||
envelope = smartreceive(msg, fileserverDownloadHandler)
|
||||
for (dataname, data, type) in envelope["payloads"]
|
||||
env = smartreceive(msg, fileserverDownloadHandler)
|
||||
for (dataname, data, type) in env["payloads"]
|
||||
if type == "text"
|
||||
println("Received from Python: $data")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user