mirror of
https://github.com/logos-messaging/nim-sds.git
synced 2026-01-08 00:53:13 +00:00
adding NewReliabilityManager
This commit is contained in:
parent
cff4062410
commit
b90387799a
@ -28,12 +28,7 @@ typedef void (*SdsCallBack) (int callerRet, const char* msg, size_t len, void* u
|
||||
* @param channelId A unique identifier for the communication channel.
|
||||
* @return An opaque handle (void*) representing the instance, or NULL on failure.
|
||||
*/
|
||||
void* sds_reliability_manager_new(char* channelId);
|
||||
|
||||
/* void* waku_new(
|
||||
const char* configJson,
|
||||
WakuCallBack callback,
|
||||
void* userData); */
|
||||
void* NewReliabilityManager(char* channelId);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -13,6 +13,7 @@ import
|
||||
./alloc,
|
||||
./ffi_types,
|
||||
./sds_thread/inter_thread_communication/sds_thread_request,
|
||||
./sds_thread/inter_thread_communication/requests/sds_lifecycle_request,
|
||||
../src/[reliability, reliability_utils, message]
|
||||
|
||||
################################################################################
|
||||
@ -102,3 +103,42 @@ proc initializeLibrary() {.exported.} =
|
||||
|
||||
### End of library setup
|
||||
################################################################################
|
||||
|
||||
################################################################################
|
||||
### Exported procs
|
||||
|
||||
proc NewReliabilityManager(
|
||||
channelId: cstring, callback: SdsCallback, userData: pointer
|
||||
): pointer {.dynlib, exportc, cdecl.} =
|
||||
initializeLibrary()
|
||||
|
||||
## Creates a new instance of the WakuNode.
|
||||
if isNil(callback):
|
||||
echo "error: missing callback in NewReliabilityManager"
|
||||
return nil
|
||||
|
||||
## Create the SDS thread that will keep waiting for req from the main thread.
|
||||
var ctx = sds_thread.createSdsThread().valueOr:
|
||||
let msg = "Error in createSdsThread: " & $error
|
||||
callback(RET_ERR, unsafeAddr msg[0], cast[csize_t](len(msg)), userData)
|
||||
return nil
|
||||
|
||||
ctx.userData = userData
|
||||
|
||||
let retCode = handleRequest(
|
||||
ctx,
|
||||
RequestType.LIFECYCLE,
|
||||
SdsLifecycleRequest.createShared(
|
||||
SdsLifecycleMsgType.CREATE_RELIABILITY_MANAGER, channelId
|
||||
),
|
||||
callback,
|
||||
userData,
|
||||
)
|
||||
|
||||
if retCode == RET_ERR:
|
||||
return nil
|
||||
|
||||
return ctx
|
||||
|
||||
### End of exported procs
|
||||
################################################################################
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user