From 0c2cca30ed8ec3d60c5c4fe80d6518fb09f728b9 Mon Sep 17 00:00:00 2001 From: narawat Date: Mon, 23 Feb 2026 20:34:08 +0700 Subject: [PATCH] update --- README.md | 15 +++++++++------ src/NATSBridge.jl | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 24b122f..ca5bc44 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,7 @@ from nats_bridge import smartsend # Send a text message data = [("message", "Hello World", "text")] -env = smartsend("/chat/room1", data, nats_url="nats://localhost:4222") +env, msg_json_str = smartsend("/chat/room1", data, nats_url="nats://localhost:4222") print("Message sent!") ``` @@ -183,7 +183,7 @@ print("Message sent!") const { smartsend } = require('./src/NATSBridge'); // Send a text message -await smartsend("/chat/room1", [ +const { env, msg_json_str } = await smartsend("/chat/room1", [ { dataname: "message", data: "Hello World", type: "text" } ], { natsUrl: "nats://localhost:4222" }); @@ -197,7 +197,7 @@ using NATSBridge # Send a text message data = [("message", "Hello World", "text")] -env = NATSBridge.smartsend("/chat/room1", data, nats_url="nats://localhost:4222") +env, msg_json_str = NATSBridge.smartsend("/chat/room1", data, nats_url="nats://localhost:4222") println("Message sent!") ``` @@ -323,7 +323,8 @@ env = smartsend( receiver_name="", # Receiver name (empty = broadcast) receiver_id="", # Receiver UUID (empty = broadcast) reply_to="", # Reply topic - reply_to_msg_id="" # Reply message ID + reply_to_msg_id="", # Reply message ID + is_publish=True # Whether to automatically publish to NATS ) ``` @@ -346,7 +347,8 @@ const env = await smartsend( receiverName: "", receiverId: "", replyTo: "", - replyToMsgId: "" + replyToMsgId: "", + isPublish: true // Whether to automatically publish to NATS } ); ``` @@ -369,7 +371,8 @@ env, msg_json_str = NATSBridge.smartsend( receiver_name::String = "", receiver_id::String = "", reply_to::String = "", - reply_to_msg_id::String = "" + reply_to_msg_id::String = "", + is_publish::Bool = true # Whether to automatically publish to NATS ) # Returns: (msgEnvelope_v1, JSON string) # - env: msgEnvelope_v1 object with all envelope metadata and payloads diff --git a/src/NATSBridge.jl b/src/NATSBridge.jl index 42185ad..d5aae71 100644 --- a/src/NATSBridge.jl +++ b/src/NATSBridge.jl @@ -377,9 +377,9 @@ Each payload can have a different type, enabling mixed-content messages (e.g., c - `fileserverUploadHandler::Function = plik_oneshot_upload` - Function to handle fileserver uploads (must return Dict with "status", "uploadid", "fileid", "url" keys) - `size_threshold::Int = DEFAULT_SIZE_THRESHOLD` - Threshold in bytes separating direct vs link transport - `correlation_id::Union{String, Nothing} = nothing` - Optional correlation ID for tracing; if `nothing`, a UUID is generated - - `msg_purpose::String = "chat"` - Purpose of the message: "ACK", "NACK", "updateStatus", "shutdown", "chat", etc. - - `sender_name::String = "default"` - Name of the sender - - `receiver_name::String = ""` - Name of the receiver (empty string means broadcast) + - `msg_purpose::String = "chat"` - Purpose of the message: "ACK", "NACK", "updateStatus", "shutdown", "chat", etc. + - `sender_name::String = "NATSBridge"` - Name of the sender + - `receiver_name::String = ""` - Name of the receiver (empty string means broadcast) - `receiver_id::String = ""` - UUID of the receiver (empty string means broadcast) - `reply_to::String = ""` - Topic to reply to (empty string if no reply expected) - `reply_to_msg_id::String = ""` - Message ID this message is replying to @@ -427,7 +427,7 @@ function smartsend( size_threshold::Int = DEFAULT_SIZE_THRESHOLD, correlation_id::Union{String, Nothing} = nothing, msg_purpose::String = "chat", - sender_name::String = "default", + sender_name::String = "NATSBridge", receiver_name::String = "", receiver_id::String = "", reply_to::String = "",