Open aaronpk opened 6 years ago
Regarding new entries, it should be only for the ones that a client chooses to subscribe to (this way, you can subscribe to notifications, a “catch-all” timeline and maybe one crafted particularity for an event).
(Originally published at: https://v2.jacky.wtf/post/6fd5c090-e0be-4030-9267-faf5517b6fcd)
@aaronpk what about WebSockets?
I'm thinking along the lines of this:
Another case to be handled somehow is updating the posts that client already has (edits, webmentions count, etc.)
I'm going to experiment with this in a few weeks.
I have tried building the server and client part for EventSource in Ekster, but found that it was quite difficult to get this working with authentication because it was hard to add Authorization headers.
The thing I like about EventSource is it's still HTTP, and doesn't require adding another client library into the project (like Websockets). Websockets is also technically overkill since we don't need bi-directional communication for this, just one way.
@aaronpk: with bi-directional you can send commands for pausing the stream, e.g., when switching to another tab.
I tried to implement something with EventSource. EventSource itself works great, but I'm not sure how to authenticate it.
This video shows how I can update the unread count of the Home channel. https://www.youtube.com/watch?v=U6gJS9nS220
Here is another video where the items are added automatically to the current timeline. The post is added by curl using Micropub. https://www.youtube.com/watch?v=tKhBKAqqBBs
I've been experimenting with the idea of real-time updates in Lwa. It's still rough around the edges but I'm planning to implement a bit of what I mentioned on my site, namely:
{
"name": "Notifications",
"uid": "notifications",
"subscriptions": [
{"type": "websocket", url: "wss://lwa.black.af/endpoints/microsub/ws?action=timeline&channel=notifications"},
{"type": "eventsource", url: "https://lwa.black.af/endpoints/eventsource/channels/notifications"}
]
}
That route could be authenticated the same way as the Microsub endpoint. I made a change to the sample in my original post so that the 'plumbing' needed to connect and subscribe was explicit - less guesswork for clients.
Clients should have a way to tap in to some sort of streaming API to get updates from the server in realtime.
I've had good luck with the EventSource API on both the client and server side of it. We should define a list of event types that map to the different Microsub actions, so that there's a way for the server to push new events to the client. Things like: