Emulsion should optionally support Matrix on the same principles as Telegram and XMPP.
Implementation Notes
A new messaging protocol requires two main things:
-
MessageSenderContext:
|
type MessageSenderContext = { |
|
Send: OutgoingMessage -> Async<unit> |
|
Logger: ILogger |
|
RestartCooldown: TimeSpan |
|
} |
(essentially one function)
-
an implementation of IMessageSystem:
|
/// The IM message queue. Manages the underlying connection, reconnects when necessary, stores the outgoing messages in |
|
/// a queue and sends them when possible. Redirects the incoming messages to a function passed when starting the queue. |
|
type IMessageSystem = |
|
/// Starts the IM connection, manages reconnects. Never terminates unless cancelled. |
|
abstract member RunSynchronously : IncomingMessageReceiver -> unit |
|
|
|
/// Queues the message to be sent to the IM system when possible. |
|
abstract member PutMessage : OutgoingMessage -> unit |
or MessageSystemBase:
|
type MessageSystemBase(ctx: ServiceContext, cancellationToken: CancellationToken) as this = |
(essentialy three functions — Send, RunUntilError, RunAsync, I barely remember why there are two Runs, but perhaps this is connected with some wacky Telegram bot interaction protocol; we have the docs though!)
-
message "muxer" is already implemented in the MessagingCore:
It will need to be adjusted for three message types.
-
message "demuxer" is kinda available as MessageSender:
|
let internal receiver (ctx: MessageSenderContext) (inbox: Sender): Async<unit> = |
— it uses persistent queue and sending retry. No need to adjust that, an implementation of aforementioned MessageSenderContext will be enough.,
Emulsion should optionally support Matrix on the same principles as Telegram and XMPP.
Implementation Notes
A new messaging protocol requires two main things:
MessageSenderContext:emulsion/Emulsion.Messaging/MessageSender.fs
Lines 13 to 17 in 715bce9
an implementation of
IMessageSystem:emulsion/Emulsion.Messaging/MessageSystem.fs
Lines 14 to 21 in 715bce9
MessageSystemBase:emulsion/Emulsion.Messaging/MessageSystem.fs
Line 46 in 715bce9
Send,RunUntilError,RunAsync, I barely remember why there are twoRuns, but perhaps this is connected with some wacky Telegram bot interaction protocol; we have the docs though!)message "muxer" is already implemented in the
MessagingCore:emulsion/Emulsion/MessagingCore.fs
Line 17 in 715bce9
message "demuxer" is kinda available as
MessageSender:emulsion/Emulsion.Messaging/MessageSender.fs
Line 66 in 715bce9
MessageSenderContextwill be enough.,