2026-02-05 01:51:10 +01:00
|
|
|
import ffi
|
|
|
|
|
import waku/factory/waku
|
|
|
|
|
|
2026-02-13 11:59:42 +01:00
|
|
|
declareLibrary("logosdelivery")
|
2026-02-05 01:51:10 +01:00
|
|
|
|
2026-02-14 01:03:47 +01:00
|
|
|
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
|
|
|
|
|
|
2026-02-13 11:59:42 +01:00
|
|
|
proc logosdelivery_set_event_callback(
|
2026-02-05 01:51:10 +01:00
|
|
|
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
|
|
|
|
) {.dynlib, exportc, cdecl.} =
|
2026-02-14 01:03:47 +01:00
|
|
|
if isNil(ctx):
|
|
|
|
|
echo "error: invalid context in logosdelivery_set_event_callback"
|
|
|
|
|
return
|
|
|
|
|
|
2026-02-05 01:51:10 +01:00
|
|
|
ctx[].eventCallback = cast[pointer](callback)
|
|
|
|
|
ctx[].eventUserData = userData
|