Repository navigation
Open
Description
Emulsion should optionally support Matrix on the same principles as Telegram and XMPP.
Implementation Notes
A new messaging protocol requires two main things:
-
MessageSenderContext:(essentially one function)emulsion/Emulsion.Messaging/MessageSender.fs
Lines 13 to 17 in 715bce9
type MessageSenderContext = { Send: OutgoingMessage -> Async<unit> Logger: ILogger RestartCooldown: TimeSpan } -
an implementation of
IMessageSystem:oremulsion/Emulsion.Messaging/MessageSystem.fs
Lines 14 to 21 in 715bce9
/// 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 MessageSystemBase:(essentialy three functions —type MessageSystemBase(ctx: ServiceContext, cancellationToken: CancellationToken) as this = 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:It will need to be adjusted for three message types.emulsion/Emulsion/MessagingCore.fs
Line 17 in 715bce9
type MessagingCore( -
message "demuxer" is kinda available as
MessageSender:— it uses persistent queue and sending retry. No need to adjust that, an implementation of aforementionedlet internal receiver (ctx: MessageSenderContext) (inbox: Sender): Async<unit> = MessageSenderContextwill be enough.,
Activity