mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-03-01 14:43:12 +00:00
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
|