[fpc-pascal] JSON RPC send server request to client

Wayne Sherman wsherman at gmail.com
Sun Oct 2 18:24:50 CEST 2022


Michael wrote:
> There is no way to send data from server to client,
> only responses to client requests.
> What's more, HTTP 1 and 1.1 simplu do not allow this.
> You'd need HTTP2 and/or websockets in order to
> send data from server to client.

>From the spec, JSON-RPC 2.0 is "transport agnostic in that the
concepts can be used within the same process, over sockets, over http,
or in many various message passing environments."
https://www.jsonrpc.org/specification#overview

Thus JSON-RPC can be used bi-directionally when using UNIX domain
sockets, TCP sockets, and other bidirectional transports (e.g
websockets).

If implemented as such using a bi-direction transport, the endpoints
can be both a server and a client at the same time, i.e. both
endpoints can issue requests and/or handle responses:
https://www.jsonrpc.org/specification#conventions

"The Client is defined as the origin of Request objects and the
handler of Response objects.
The Server is defined as the origin of Response objects and the
handler of Request objects.
One implementation of this specification could easily fill both of
those roles, even at the same time, to other different clients or the
same client. This specification does not address that layer of
complexity."


More information about the fpc-pascal mailing list