Currently XRPC endpoints can be declared as queries (client to server), procedures (client to server), or subscriptions (server to client).
However the mechanism for subscriptions, websockets, supports bidirectional communication. Additionally for any stateful service websockets significantly outperform traditional http POST requests due to the persistent nature of their connection.
The approach I’ve used for corvus.page, chaos.soccer, and deception.town is to establish a set of backchannel frames. This is a lexicon union type that declare the messages that can be sent from client to server on the subscription connection. However this is documented purely in the description of the xprc subscription.
What I’d propose is an extension to the subscription type that allows for these messages to become first class members. The extension would do the following.
- Define the messages that a client can send to the server on the websocket
- Define a authorization (beyond what is required for the basic subscription) that is required to send data.
On the second point in particular there are a number of cases where the subscription may carry public data from the server to the client, but carry private data from the client to the server. This requires us to authenticate for bidirectional sending but not for a standard subscription.