caolan / mutiny

Peer-to-peer web applications runtime
5 stars 1 forks source link

Event notifications #14

Closed caolan closed 3 months ago

caolan commented 5 months ago

For example, the list of discovered peers in examples/ping is currently polling the mutiny-app API every second to get the latest list. Ideally, the frontend would be notified when another peer is discovered.

There will be many other events in future that we'll want to notify clients about and we need a mechanism for doing this.

caolan commented 3 months ago

The mutinyd protocol has been updated to handle multiplexing. Previously each request had to wait for its response before the next request could be sent. Now, each request send an ID which is used in the response so the client knows which request is being responded to. Responses may be sent in any order and certain requests may even receive multiple responses (e.g. subscribing to events).

Requests look like this:

{id: <number>, body: <request data>}

And responses look like:

{request_id: <number>, body: <response data>}