mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-04 06:53:12 +00:00
Added events and requests for support. Reworked delivery_monitor into a featured devlivery_service, that - supports relay publish and lightpush depending on configuration but with fallback options - if available and configured it utilizes store api to confirm message delivery - emits message delivery events accordingly Notice: There are parts still in WIP and needs review and follow ups. prepare for use in api_example
37 lines
1.1 KiB
Nim
37 lines
1.1 KiB
Nim
## This module helps to ensure the correct transmission and reception of messages
|
|
|
|
import results
|
|
import chronos
|
|
import
|
|
./recv_service,
|
|
./send_service,
|
|
waku/[
|
|
waku_core,
|
|
waku_node,
|
|
waku_store/client,
|
|
waku_relay/protocol,
|
|
waku_lightpush/client,
|
|
waku_filter_v2/client,
|
|
]
|
|
|
|
type DeliveryService* = ref object
|
|
sendService*: SendService
|
|
recvService: RecvService
|
|
|
|
proc new*(
|
|
T: type DeliveryService, useP2PReliability: bool, w: WakuNode
|
|
): Result[T, string] =
|
|
## storeClient is needed to give store visitility to DeliveryService
|
|
## wakuRelay and wakuLightpushClient are needed to give a mechanism to SendService to re-publish
|
|
let sendService = ?SendService.new(useP2PReliability, w)
|
|
let recvService = RecvService.new(w)
|
|
return ok(DeliveryService(sendService: sendService, recvService: recvService))
|
|
|
|
proc startDeliveryService*(self: DeliveryService) =
|
|
self.sendService.startSendService()
|
|
self.recvService.startRecvService()
|
|
|
|
proc stopDeliveryService*(self: DeliveryService) {.async.} =
|
|
self.sendService.stopSendService()
|
|
await self.recvService.stopRecvService()
|