mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-10 22:16:40 +00:00
21 lines
651 B
Nim
21 lines
651 B
Nim
import system, std/json, libp2p/[connmanager, peerid]
|
|
|
|
import ../../waku/common/base64, ./json_base_event
|
|
|
|
type JsonConnectionChangeEvent* = ref object of JsonEvent
|
|
peerId*: PeerId
|
|
peerEvent*: PeerEventKind
|
|
|
|
proc new*(
|
|
T: type JsonConnectionChangeEvent, peerId: PeerId, peerEvent: PeerEventKind
|
|
): T =
|
|
# Returns a JsonConnectionChangeEvent event as indicated in
|
|
# https://rfc.vac.dev/spec/36/#jsonmessageevent-type
|
|
|
|
return JsonConnectionChangeEvent(
|
|
eventType: "connection_change", peerId: peerId, peerEvent: peerEvent
|
|
)
|
|
|
|
method `$`*(jsonConnectionChangeEvent: JsonConnectionChangeEvent): string =
|
|
$(%*jsonConnectionChangeEvent)
|