mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-27 15:16:05 +00:00
1e8f577104
* libwaku: Avoid global variable and changing callback signature * Better signature for the callback. Two new parameters have been added: one aimed to allow passing the caller result code; the other param is to pass an optional userData pointer that might need to be linked locally with the Context object. For example, this is needed in Rust to make the passed closures live as long as the Context. * waku_example.c: adaptation to the latest changes * libwaku.h: removing 'waku_set_user_data' function * libwaku.nim: renaming parameter in WakuCallBack (isOk -> callerRet)
91 lines
2.8 KiB
C
91 lines
2.8 KiB
C
|
|
// Generated manually and inspired by the one generated by the Nim Compiler.
|
|
// In order to see the header file generated by Nim just run `make libwaku`
|
|
// from the root repo folder and the header should be created in
|
|
// nimcache/release/libwaku/libwaku.h
|
|
#ifndef __libwaku__
|
|
#define __libwaku__
|
|
|
|
// The possible returned values for the functions that return int
|
|
#define RET_OK 0
|
|
#define RET_ERR 1
|
|
#define RET_MISSING_CALLBACK 2
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef void (*WakuCallBack) (int callerRet, const char* msg, size_t len);
|
|
|
|
// Initializes the waku library and returns a pointer to the Context.
|
|
void* waku_init(WakuCallBack callback,
|
|
void* userData);
|
|
|
|
// Creates a new instance of the waku node.
|
|
// Sets up the waku node from the given configuration.
|
|
int waku_new(void* ctx,
|
|
const char* configJson,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
int waku_start(void* ctx,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
int waku_stop(void* ctx,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
int waku_version(void* ctx,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
void waku_set_event_callback(WakuCallBack callback,
|
|
void* userData);
|
|
|
|
int waku_content_topic(void* ctx,
|
|
const char* appName,
|
|
unsigned int appVersion,
|
|
const char* contentTopicName,
|
|
const char* encoding,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
int waku_pubsub_topic(void* ctx,
|
|
const char* topicName,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
int waku_default_pubsub_topic(void* ctx,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
int waku_relay_publish(void* ctx,
|
|
const char* pubSubTopic,
|
|
const char* jsonWakuMessage,
|
|
unsigned int timeoutMs,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
int waku_relay_subscribe(void* ctx,
|
|
const char* pubSubTopic,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
int waku_relay_unsubscribe(void* ctx,
|
|
const char* pubSubTopic,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
int waku_connect(void* ctx,
|
|
const char* peerMultiAddr,
|
|
unsigned int timeoutMs,
|
|
WakuCallBack callback,
|
|
void* userData);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __libwaku__ */
|