From 28ed908c0f71ca7cdb149c3188ea61626fb92f6c Mon Sep 17 00:00:00 2001 From: Aya Hassan Date: Mon, 9 Mar 2026 18:48:25 +0100 Subject: [PATCH] Adding wrapper for new APIs --- waku/wrapper.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/waku/wrapper.py b/waku/wrapper.py index 55bf93e..45479fd 100644 --- a/waku/wrapper.py +++ b/waku/wrapper.py @@ -56,6 +56,13 @@ int logosdelivery_unsubscribe( void *userData, const char *contentTopic ); + +int logosdelivery_send( + void *ctx, + FFICallBack callback, + void *userData, + const char *messageJson +); """ ) @@ -242,4 +249,21 @@ class NodeWrapper: if rc != 0: return Err(f"unsubscribe_content_topic: immediate call failed (ret={rc})") - return _wait_cb(state, f"unsubscribe({content_topic})", timeout_s) \ No newline at end of file + return _wait_cb(state, f"unsubscribe({content_topic})", timeout_s) + + def send_message(self, message: dict, *, timeout_s: float = 20.0) -> Result[int, str]: + state = _new_cb_state() + cb = self._make_waiting_cb(state) + + message_json = json.dumps(message, separators=(",", ":"), ensure_ascii=False) + + rc = lib.logosdelivery_send( + self.ctx, + cb, + ffi.NULL, + message_json.encode("utf-8"), + ) + if rc != 0: + return Err(f"send_message: immediate call failed (ret={rc})") + + return _wait_cb(state, "send_message", timeout_s) \ No newline at end of file