JSTP is an RPC protocol and framework which provides two-way asynchronous data transfer with support of multiple parallel non-blocking interactions that is so transparent that an app may not even distinguish between local async functions and remote procedures.
And, as a nice bonus, there's a blazing fast JSON5 implementation bundled in!
This project is bound by a Code of Conduct.
Installation
JSTP works in Node.js and web browsers:
$ npm install --save metarhia-jstp
Or, alternatively, there are jstp.min.js and jstp.min.js.map available for those browser-based applications that aren't built using a module bundler like webpack.
We also have official client-side implementations for Swift and Java that work effortlessly on iOS and Android 🎉
Getting Started
Server:
'use strict'; const jstp = ; // Application is the core high-level abstraction of the framework. An app// consists of a number of interfaces, and each interface has its methods.const app = 'testApp' someService: { ; } ; // Let's create a TCP server for this app. Other available transports are// WebSocket and Unix domain sockets. One might notice that an array of// applications is passed the `createServer()`. That's because it can serve// any number of applications.const server = jstpnet;server;
Client:
'use strict'; const jstp = ; // Create a TCP connection to server and connect to the `testApp` application.// Clients can have applications too for full-duplex RPC,// but we don't need that in this example. Client is `null` in this example,// this implies that username and password are both `null`// here — that is, the protocol-level authentication is not leveraged in this// example. The next argument is an array of interfaces to inspect and build// remote proxy objects for. Remaining arguments are for// net.connect (host and port) and last argument is a callback// to be called on successful connection or error.jstpnet; { if error console; return; // The `app` object contains remote proxy objects for each interface that has // been requested which allow to use remote APIs as regular async functions. // Remote proxies are also `EventEmitter`s: they can be used to `.emit()` // events to another side of a connection and listen to them using `.on()`. appsomeService;}
Project Maintainers
Kudos to @tshemsedinov for the initial idea and proof-of-concept implementation. Current project team is:
- @aqrln — Alexey Orlenko <eaglexrlnk@gmail.com>
- @belochub — Mykola Bilochub <nbelochub@gmail.com>
- @lundibundi — Denys Otrishko <shishugi@gmail.com>
- @nechaido — Dmytro Nechai <nechaido@gmail.com>
- @tshemsedinov — Timur Shemsedinov <timur.shemsedinov@gmail.com>