mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-02-18 12:53:09 +00:00
* Initial for liblogosdelivery library (static & dynamic) based on current state of API. * nix build support added. * logosdelivery_example * Added support for missing logLevel/logFormat in new API create_node * Added full JSON to NodeConfig support * Added ctx and ctx.myLib check to avoid uninitialzed calls and crash. Adjusted logosdelivery_example with proper error handling and JSON config format * target aware install phase * Fix base64 decode of payload
25 lines
719 B
Nim
25 lines
719 B
Nim
import ffi
|
|
import waku/factory/waku
|
|
|
|
declareLibrary("logosdelivery")
|
|
|
|
template requireInitializedNode*(
|
|
ctx: ptr FFIContext[Waku], opName: string, onError: untyped
|
|
) =
|
|
if isNil(ctx):
|
|
let errMsg {.inject.} = opName & " failed: invalid context"
|
|
onError
|
|
elif isNil(ctx.myLib) or isNil(ctx.myLib[]):
|
|
let errMsg {.inject.} = opName & " failed: node is not initialized"
|
|
onError
|
|
|
|
proc logosdelivery_set_event_callback(
|
|
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
|
) {.dynlib, exportc, cdecl.} =
|
|
if isNil(ctx):
|
|
echo "error: invalid context in logosdelivery_set_event_callback"
|
|
return
|
|
|
|
ctx[].eventCallback = cast[pointer](callback)
|
|
ctx[].eventUserData = userData
|