update readme

This commit is contained in:
2026-05-23 10:57:01 +07:00
parent 31727f3337
commit 15a7f1c178
3 changed files with 12 additions and 9 deletions

View File

@@ -107,11 +107,14 @@ msghandler enables seamless communication across multiple platforms through NATS
#### Julia #### Julia
```julia ```julia
using msghandler using msghandler, NATS
data = [("message", "Hello World", "text")] data = [("message", "Hello World", "text")]
env, env_json_str = smartpack("/chat/room1", data; broker_url="nats://localhost:4222") 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) #### JavaScript (Node.js)

View File

@@ -9,7 +9,7 @@
using NATS, JSON, UUIDs, Dates, PrettyPrinting, DataFrames, Arrow, HTTP, Base64 using NATS, JSON, UUIDs, Dates, PrettyPrinting, DataFrames, Arrow, HTTP, Base64
# Include the bridge module # Include the bridge module
include("../src/msghandler.jl") include("/home/ton/docker-apps/sommpanion/msghandler/src/msghandler.jl")
using .msghandler using .msghandler
# Configuration # Configuration
@@ -39,7 +39,7 @@ function test_mix_receive()
# Use msghandler.smartunpack to handle the data # Use msghandler.smartunpack to handle the data
# API: smartunpack(msg, download_handler; max_retries, base_delay, max_delay) # API: smartunpack(msg, download_handler; max_retries, base_delay, max_delay)
result = msghandler.smartunpack( result = msghandler.smartunpack(
msg; env_json_str;
max_retries = 5, max_retries = 5,
base_delay = 100, base_delay = 100,
max_delay = 5000 max_delay = 5000

View File

@@ -14,7 +14,7 @@
using NATS, JSON, UUIDs, Dates, PrettyPrinting, DataFrames, Arrow, HTTP, Base64 using NATS, JSON, UUIDs, Dates, PrettyPrinting, DataFrames, Arrow, HTTP, Base64
# Include the bridge module # Include the bridge module
include("../src/msghandler.jl") include("/home/ton/docker-apps/sommpanion/msghandler/src/msghandler.jl")
using .msghandler using .msghandler
# Configuration # Configuration
@@ -204,7 +204,7 @@ function test_mix_send()
] ]
# Use smartpack with mixed content # Use smartpack with mixed content
sendinfo = msghandler.smartpack( env, env_json_str = msghandler.smartpack(
SUBJECT, SUBJECT,
payloads; # List of (dataname, data, type) tuples payloads; # List of (dataname, data, type) tuples
broker_url = NATS_URL, broker_url = NATS_URL,
@@ -218,10 +218,8 @@ function test_mix_send()
receiver_id = "", receiver_id = "",
reply_to = "", reply_to = "",
reply_to_msg_id = "", 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_trace("Sent message with $(length(env.payloads)) payloads")
# Log transport type for each payload # Log transport type for each payload
@@ -243,6 +241,8 @@ function test_mix_send()
link_count = count(p -> p.transport == "link", env.payloads) link_count = count(p -> p.transport == "link", env.payloads)
log_trace("Direct transport: $direct_count payloads") log_trace("Direct transport: $direct_count payloads")
log_trace("Link transport: $link_count payloads") log_trace("Link transport: $link_count payloads")
return env_json_str
end end
@@ -252,7 +252,7 @@ println("Correlation ID: $correlation_id")
# Run sender # Run sender
println("start smartpack for mixed content") println("start smartpack for mixed content")
test_mix_send() env_json_str = test_mix_send()
println("\nTest completed.") println("\nTest completed.")
println("Note: Run test_julia_to_julia_mix_receiver.jl to receive the messages.") println("Note: Run test_julia_to_julia_mix_receiver.jl to receive the messages.")