update readme
This commit is contained in:
@@ -107,11 +107,14 @@ msghandler enables seamless communication across multiple platforms through NATS
|
||||
#### Julia
|
||||
|
||||
```julia
|
||||
using msghandler
|
||||
using msghandler, NATS
|
||||
|
||||
|
||||
data = [("message", "Hello World", "text")]
|
||||
env, env_json_str = smartpack("/chat/room1", data; broker_url="nats://localhost:4222")
|
||||
println("Message sent!")
|
||||
conn = NATS.connect(broker_url) # Create NATS connection
|
||||
NATS.publish(conn, subject, message) # Publish message to NATS
|
||||
NATS.drain(conn)
|
||||
```
|
||||
|
||||
#### JavaScript (Node.js)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
using NATS, JSON, UUIDs, Dates, PrettyPrinting, DataFrames, Arrow, HTTP, Base64
|
||||
|
||||
# Include the bridge module
|
||||
include("../src/msghandler.jl")
|
||||
include("/home/ton/docker-apps/sommpanion/msghandler/src/msghandler.jl")
|
||||
using .msghandler
|
||||
|
||||
# Configuration
|
||||
@@ -39,7 +39,7 @@ function test_mix_receive()
|
||||
# Use msghandler.smartunpack to handle the data
|
||||
# API: smartunpack(msg, download_handler; max_retries, base_delay, max_delay)
|
||||
result = msghandler.smartunpack(
|
||||
msg;
|
||||
env_json_str;
|
||||
max_retries = 5,
|
||||
base_delay = 100,
|
||||
max_delay = 5000
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
using NATS, JSON, UUIDs, Dates, PrettyPrinting, DataFrames, Arrow, HTTP, Base64
|
||||
|
||||
# Include the bridge module
|
||||
include("../src/msghandler.jl")
|
||||
include("/home/ton/docker-apps/sommpanion/msghandler/src/msghandler.jl")
|
||||
using .msghandler
|
||||
|
||||
# Configuration
|
||||
@@ -204,7 +204,7 @@ function test_mix_send()
|
||||
]
|
||||
|
||||
# Use smartpack with mixed content
|
||||
sendinfo = msghandler.smartpack(
|
||||
env, env_json_str = msghandler.smartpack(
|
||||
SUBJECT,
|
||||
payloads; # List of (dataname, data, type) tuples
|
||||
broker_url = NATS_URL,
|
||||
@@ -218,10 +218,8 @@ function test_mix_send()
|
||||
receiver_id = "",
|
||||
reply_to = "",
|
||||
reply_to_msg_id = "",
|
||||
is_publish = true # Publish the message to NATS
|
||||
)
|
||||
|
||||
env, env_json_str = sendinfo
|
||||
log_trace("Sent message with $(length(env.payloads)) payloads")
|
||||
|
||||
# Log transport type for each payload
|
||||
@@ -243,6 +241,8 @@ function test_mix_send()
|
||||
link_count = count(p -> p.transport == "link", env.payloads)
|
||||
log_trace("Direct transport: $direct_count payloads")
|
||||
log_trace("Link transport: $link_count payloads")
|
||||
|
||||
return env_json_str
|
||||
end
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ println("Correlation ID: $correlation_id")
|
||||
|
||||
# Run sender
|
||||
println("start smartpack for mixed content")
|
||||
test_mix_send()
|
||||
env_json_str = test_mix_send()
|
||||
|
||||
println("\nTest completed.")
|
||||
println("Note: Run test_julia_to_julia_mix_receiver.jl to receive the messages.")
|
||||
|
||||
Reference in New Issue
Block a user