realtime-ts
A real time engine using websocket with node and typescript. This project also adds support for local dbs using indexedDB and synchronization with remote databases such as mongo db.
Handlers
Handlers are present on the common interface as they serve both sides. With handler you can define a name and the implementation of a method that can be called from a remote source.
Server Side handlers can be called from the client using a websocket. Something similar to a Remote Procedure Call.
Client Side handlers can be called from the server to execute actions on the client side.
There can be only one handler per name, by definition.
const handlers = ;handlers;
That can be invoked in a later part of your code. Handlers can return a value. Always wrapped in a promise.
handlers;
or
const r: Promise<number> = handlers;r;
Or it can be removed by calling:
handlers;
Listeners
Another common implementation on both the server and the client is the use of listeners. A listener does not returns anything. Multiple functions can listen to an event and they work very well for notification messages.
const listeners = ;listeners;listeners;
Those methods are attached to a named event that can be called:
listeners;
Listeners can be removed using the removeListener method on the class.
Those are the core concepts on both the client and the server. You'll find addHandler, addListener, removeHandler, removeListener, invoke and notify on a lot of the classes in this implementation.
The Server
The Realtime server implements the standard node http or https createServer method and we use the ws library to create a socket attached to that server.
const server = ;server;server;
The Client
The realtime client uses a browser websocket implementation to connect to a realtime server.
const client = "ws://localhost:1337";const result: Promise<string> = client;result;
In Between: JSON RPC
Please check the documentation for JSON RPC on this markdown documentation and feel free to collaborate and edit.
Realtime Database
Please check the documentation for the realtime database implemented using this library on this markdown documentation and feel free to collaborate and edit.