mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-06-27 20:10:02 +00:00
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>
10 lines
446 B
Nim
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)
|