Adding wrapper for new APIs

This commit is contained in:
Aya Hassan 2026-03-09 18:48:25 +01:00
parent e4ae16fe0f
commit 28ed908c0f

View File

@ -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)
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)