update
This commit is contained in:
16
README.md
16
README.md
@@ -356,7 +356,7 @@ const env = await smartsend(
|
||||
```julia
|
||||
using NATSBridge
|
||||
|
||||
env = NATSBridge.smartsend(
|
||||
env, msg_json_str = NATSBridge.smartsend(
|
||||
subject; # NATS subject
|
||||
data::AbstractArray{Tuple{String, Any, String}}; # List of (dataname, data, type)
|
||||
nats_url::String = "nats://localhost:4222",
|
||||
@@ -371,6 +371,9 @@ env = NATSBridge.smartsend(
|
||||
reply_to::String = "",
|
||||
reply_to_msg_id::String = ""
|
||||
)
|
||||
# Returns: (msgEnvelope_v1, JSON string)
|
||||
# - env: msgEnvelope_v1 object with all envelope metadata and payloads
|
||||
# - msg_json_str: JSON string representation of the envelope for publishing
|
||||
```
|
||||
|
||||
### smartreceive
|
||||
@@ -636,19 +639,24 @@ data = [("students", df, "table")]
|
||||
NATSBridge.smartsend("/data/analysis", data)
|
||||
```
|
||||
|
||||
### Example 4: Request-Response Pattern
|
||||
### Example 4: Request-Response Pattern with Envelope JSON
|
||||
|
||||
Bi-directional communication with reply-to support.
|
||||
Bi-directional communication with reply-to support. The `smartsend` function now returns both the envelope object and a JSON string that can be published directly.
|
||||
|
||||
#### Python/Micropython (Requester)
|
||||
```python
|
||||
from nats_bridge import smartsend
|
||||
|
||||
env = smartsend(
|
||||
env, msg_json_str = smartsend(
|
||||
"/device/command",
|
||||
[("command", {"action": "read_sensor"}, "dictionary")],
|
||||
reply_to="/device/response"
|
||||
)
|
||||
# env: msgEnvelope_v1 object
|
||||
# msg_json_str: JSON string for publishing to NATS
|
||||
|
||||
# The msg_json_str can also be published directly using NATS request-reply pattern
|
||||
# nc.request("/device/command", msg_json_str, reply_to="/device/response")
|
||||
```
|
||||
|
||||
#### Python/Micropython (Responder)
|
||||
|
||||
Reference in New Issue
Block a user