update
This commit is contained in:
29
README.md
29
README.md
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user