Matrix SDK beta v3.3.0

Hey everyone! I am building a Matrix SDK that communicates with the Matrix protocol. Recently, I have published beta v3.3.0 on the public registry, which is the first (beta) version that enables API communication.

Here’s a live demo of its current features!

What is Matrix and why should I care?

Matrix is similar to email, but made for instant messaging. One can use it for instant messaging (and someone has already built a client called Scylla in Elm before) and it can also be used for other purposes like a chess client, which I’ve built using the latest alpha version.

If you don’t know about Matrix, then the biggest upside is that it offers you a free, open-source and federated back-end to exchange JSON objects with other (Elm) clients.

What is supported for now?

For now, the beta Matrix SDK only supports one feature: sending JSON objects into the world. (Not reading them yet.) The code looks something like the following:


sendMessage : Cmd Msg
sendMessage =
    Matrix.sendMessageEvent
        { content = -- JSON object that we're sending to the API
            Json.Encode.object
                [ ( "body", Json.Encode.string "hello, world!" )
                , ( "msgtype", Json.Encode.string "m.text" )
                ]
        , eventType = "m.room.message" -- Event type
        , roomId = "!abcdefg:matrix.org" -- Matrix room ID
        , toMsg = toMsg -- Our return Msg type after the API call
        , transactionId = "0123456789" -- Identifier for this message
        , vault = vault -- Value containing all credentials
        }

This code does everything necessary for communication:

  1. It finds the appropriate API endpoints;
  2. It establishes the connection;
  3. It uses a cached access token from the vault, and otherwise logs in for a new access token;
  4. It sends the message.

Effectively, the Matrix SDK gets rid of all steps necessary to upload JSON objects, and simply lets you focus on what you want to send.

Where is it going?

For now, one can only write JSON objects to the API. Obviously, the next step is to be able to read JSON objects from the API. Hopefully, this should make it trivial for Elm developers to use Matrix homeservers as a standard back-end to make their local games go online.

I have received funding from NLnet, so I will be able to spend more time into it. I am planning to make the SDK as easy to use as possible for Elm developers, so please let me know if you have any feedback! Alternatively, you can talk to me in the Matrix SDK room.


So please, any feedback is welcome! I have mostly received feedback from the Matrix ecosystem, and I’d love more feedback from people who actually write in Elm - even if you do not plan on using it. What do you think of it?

6 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.