v1.1.0-fix_JS_version #2
49
README.md
49
README.md
@@ -199,7 +199,7 @@ Add to your `Project.toml`:
|
||||
msghandler = "path-to-msghandler"
|
||||
```
|
||||
|
||||
#### Send Messages
|
||||
#### Send Messages (Publish - Subscribe Pattern)
|
||||
|
||||
```julia
|
||||
using msghandler
|
||||
@@ -229,7 +229,7 @@ NATS.drain(conn)
|
||||
reply = NATS.request(conn, "test.topic", envelope_json_str, timeout=10)
|
||||
```
|
||||
|
||||
#### Receive Messages
|
||||
#### Receive Messages (Publish - Subscribe Pattern)
|
||||
|
||||
```julia
|
||||
using msghandler, NATS
|
||||
@@ -250,6 +250,51 @@ NATS.subscribe(conn, "test.topic") do msg
|
||||
end
|
||||
```
|
||||
|
||||
#### OR
|
||||
#### Send Messages (Request - Reply Pattern)
|
||||
|
||||
```julia
|
||||
using msghandler
|
||||
|
||||
# Data format: [(dataname, data, type), ...]
|
||||
payload_1 = ("test_message", "Hello World", "text")
|
||||
file_path_large_image = "./test/large_image.png"
|
||||
file_data_large_image = read(file_path_large_image)
|
||||
filename_large_image = basename(file_path_large_image)
|
||||
payload_2 = (filename_large_image, file_data_large_image, "binary")
|
||||
|
||||
payloads = [payload_1, payload_2] # List of tuples
|
||||
|
||||
# Step 1: Create the message envelope (transport-agnostic)
|
||||
envelope, envelope_json_str = msghandler.smartpack("test.topic",
|
||||
payloads;
|
||||
broker_url="nats.yiem.cc",
|
||||
fileserver_url="http://192.168.88.104:8080")
|
||||
|
||||
# Step 2: Send via your chosen transport (NATS in this example)
|
||||
using NATS
|
||||
conn = NATS.connect("nats.yiem.cc")
|
||||
reply = NATS.request(conn, "test.topic", envelope_json_str, timeout=10)
|
||||
```
|
||||
|
||||
#### Receive Messages (Request - Reply Pattern)
|
||||
|
||||
```julia
|
||||
using msghandler, NATS
|
||||
|
||||
conn = NATS.connect("nats.yiem.cc")
|
||||
sub1 = NATS.reply(conn, "nats.yiem.cc"; queue_group="group1", spawn=true) do msg
|
||||
envelope_json_str = String(msg.payload)
|
||||
envelope = msghandler.smartunpack(envelope_json_str)
|
||||
response = [("respond_message", "msg received", "text")]
|
||||
_, envelope_json_str = msghandler.smartpack("requester inbox",
|
||||
response;
|
||||
broker_url="nats.yiem.cc",
|
||||
fileserver_url="http://192.168.88.104:8080")
|
||||
return envelope_json_str
|
||||
end
|
||||
```
|
||||
|
||||
### JavaScript CSR Webapp
|
||||
|
||||
#### Installation
|
||||
|
||||
Reference in New Issue
Block a user