LitClient - Firescar96/lit GitHub Wiki

The core of Lit-BAMF is the LitClient.

When the user first opens Lit-BAMF a connection is initialized between the browser (the client) and the Lit binary (the server). It's assumed the server can be accessed at the same hostname and port that Lit-BAMF is on. LitClient manages this connection.

Every RPC call goes through Lit-Client using the send method. Every call is given a unique id so that when a response from the server is received the appropriate caller can be retrieved and passed the response. This lets calls to JSON-RPC methods be somewhat abstracted away into a normal function call. send returns a promise that will be either be resolved with a result or rejected with an error based on the response from the server.

Functions can also be registered via the register method for an arbitrary id. This is used by the chat functionality to register for the null id. When the Lit client receives a message from the server with no id it passes the message on to the registered chat handler function.