This commit is contained in:
2026-05-23 12:02:18 +07:00
parent 15a7f1c178
commit a4f450386c
2 changed files with 26 additions and 5 deletions

View File

@@ -109,11 +109,10 @@ msghandler enables seamless communication across multiple platforms through NATS
```julia
using msghandler, NATS
data = [("message", "Hello World", "text")]
env, env_json_str = smartpack("/chat/room1", data; broker_url="nats://localhost:4222")
data = [("test_message", "Hello World", "text")] # payloads to be send format is [(dataname, data, type), ...] tuples.
envelope, envelope_json_str = smartpack("test.topic", data; broker_url="nats.yiem.cc")
conn = NATS.connect(broker_url) # Create NATS connection
NATS.publish(conn, subject, message) # Publish message to NATS
NATS.publish(conn, "test.topic", envelope_json_str) # Publish message to NATS
NATS.drain(conn)
```
@@ -174,6 +173,28 @@ env, env_json_str = smartpack(
print("Message sent!")
```
### Receive Your First Message
#### Julia
```julia
using msghandler, NATS
conn = NATS.connect("nats.yiem.cc")
NATS.subscribe(conn, "test.topic") do msg
log_trace("Received message on $(msg.subject)")
# Use NATSBridge.smartreceive to handle the data
# API: smartreceive(msg, download_handler; max_retries, base_delay, max_delay)
envelope = msghandler.smartunpack(
msg;
max_retries = 5,
base_delay = 100,
max_delay = 5000
)
end
```
---
## API Reference