Skip to content

Matrix support #451

@ForNeVeR

Description

@ForNeVeR

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:

    type 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.,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions