mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
chore: exposing online state in libwaku (#3433)
This commit is contained in:
parent
5e22ea18b6
commit
94cd2f88b4
@ -232,6 +232,10 @@ int waku_ping_peer(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_is_online(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -842,5 +842,19 @@ proc waku_ping_peer(
|
||||
userData,
|
||||
)
|
||||
|
||||
proc waku_is_online(
|
||||
ctx: ptr WakuContext, callback: WakuCallBack, userData: pointer
|
||||
): cint {.dynlib, exportc.} =
|
||||
initializeLibrary()
|
||||
checkLibwakuParams(ctx, callback, userData)
|
||||
|
||||
handleRequest(
|
||||
ctx,
|
||||
RequestType.PEER_MANAGER,
|
||||
PeerManagementRequest.createShared(PeerManagementMsgType.IS_ONLINE),
|
||||
callback,
|
||||
userData,
|
||||
)
|
||||
|
||||
### End of exported procs
|
||||
################################################################################
|
||||
|
||||
@ -15,6 +15,7 @@ type PeerManagementMsgType* {.pure.} = enum
|
||||
DIAL_PEER
|
||||
DIAL_PEER_BY_ID
|
||||
GET_CONNECTED_PEERS
|
||||
IS_ONLINE
|
||||
|
||||
type PeerManagementRequest* = object
|
||||
operation: PeerManagementMsgType
|
||||
@ -144,5 +145,7 @@ proc process*(
|
||||
(inPeerIds, outPeerIds) = waku.node.peerManager.connectedPeers()
|
||||
connectedPeerids = concat(inPeerIds, outPeerIds)
|
||||
return ok(connectedPeerids.mapIt($it).join(","))
|
||||
of IS_ONLINE:
|
||||
return ok($waku.node.peerManager.isOnline())
|
||||
|
||||
return ok("")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user