proc gen_event(ad: AddressDirection) {.async.} = let href = ("http://$1:$2/sub$3" % [ cts.host, $cts.port, $sid ]) let ev = %* CallEventNotification( callingParticipant: calling, calledParticipant: called, eventDescription: EventDescription(callEvent: evtype), notificationType: "callEvent", callSessionIdentifier: $ id, addressDirection: ad, link: Link(rel: "callEventSubscription", href: href) ) let evp = ev.pretty() debug("tx> " & evp) let url = ces.callbackReference.notifyURL let c = newAsyncHttpCLient() let req = c.post(url, body = evp) if await withTimeout(req, 1000): let r = await req if r.code() != Http204: error r.status else: debug "rx> " & await r.body else: warn("timeout")