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
|
```julia
|
||||||
using msghandler, NATS
|
using msghandler, NATS
|
||||||
|
|
||||||
|
data = [("test_message", "Hello World", "text")] # payloads to be send format is [(dataname, data, type), ...] tuples.
|
||||||
data = [("message", "Hello World", "text")]
|
envelope, envelope_json_str = smartpack("test.topic", data; broker_url="nats.yiem.cc")
|
||||||
env, env_json_str = smartpack("/chat/room1", data; broker_url="nats://localhost:4222")
|
|
||||||
conn = NATS.connect(broker_url) # Create NATS connection
|
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)
|
NATS.drain(conn)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -174,6 +173,28 @@ env, env_json_str = smartpack(
|
|||||||
print("Message sent!")
|
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
|
## API Reference
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ env, msg_json = smartpack("chat.subject", [
|
|||||||
"""
|
"""
|
||||||
function smartpack(
|
function smartpack(
|
||||||
subject::String, # smartunpack's subject
|
subject::String, # smartunpack's subject
|
||||||
data::AbstractArray{Tuple{String, T1, String}, 1}; # List of (dataname, data, type) tuples. Use Tuple{String, Any, String}[] for empty payloads
|
data::AbstractArray{Tuple{String, T1, String}, 1}; # List of (dataname, data, type) tuples. Use data = Tuple{String, Any, String}[] for empty payloads
|
||||||
broker_url::String = DEFAULT_BROKER_URL, # Broker URL
|
broker_url::String = DEFAULT_BROKER_URL, # Broker URL
|
||||||
fileserver_url = DEFAULT_FILESERVER_URL,
|
fileserver_url = DEFAULT_FILESERVER_URL,
|
||||||
fileserver_upload_handler::Function = plik_oneshot_upload, # a function to handle uploading data to specific HTTP fileserver
|
fileserver_upload_handler::Function = plik_oneshot_upload, # a function to handle uploading data to specific HTTP fileserver
|
||||||
|
|||||||
Reference in New Issue
Block a user