Ivan FB 46666044f2
channels_api: reliable-channel FFI (create/send/close + events)
Add library/channels_api over the reliable-channel logic: channel_create
returns a {.ffiHandle.} ReliableChannelHandle, channel_send/channel_close
operate on it, and the channel message received/sent/error events are fed by
the channel-layer broker events. Wire them into the FFI root.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 13:14:41 +02:00

10 lines
446 B
Nim

proc channel_send*(
ch: ReliableChannelHandle, payload: seq[byte], ephemeral: bool
): Future[Result[string, string]] {.ffi.} =
## Sends `payload` on the reliable channel. Routes through the messaging
## layer (ReliableChannelManager.send -> MessagingClient.send); returns the
## channel-layer request id.
let requestId = (await ch.manager.send(ch.channelId, payload, ephemeral)).valueOr:
return err(error)
return ok($requestId)