Implementation of RMI in Node.js
- Make sure Node.js has been installed on your machine.
- Download the repository as ZIP or use the following command:
git clone https://github.com/geraked/js-rmi.git
- Go to directory where the file
package.json
exists:
cd js-rmi
- Execute the following command to run the example:
npm run example
- Install:
npm i https://github.com/geraked/js-rmi.git
- Define an abstract class (interface) and share between the client and server:
- Implement the interface on the server:
- Create an object on the
server
and bind it:
import { ServerStub } from "rmi";
import { Human } from "./Human.js";
let stub = new ServerStub("localhost", 3000);
let human = new Human("Amir", 17, 67, 1.73);
stub.bind("/human", human);
- Lookup the remote object from the
client
and use it:
import { IHuman } from "../shared/IHuman.js";
import { ClientStub } from "rmi";
let stub = new ClientStub("localhost", 3000);
let human = stub.lookup("/human", IHuman);
console.log("toJSON:", await human.toJSON());
console.log("BMI:", await human.bmi());
// Manipulate
await (human.name = "Reza");
await (human.height = 1.8);
await (human.age = (await human.age) + 3);
await human.looseWeight(5);
Rabist - view on LinkedIn
- Course: Distributed Systems - MS
- Teacher: Dr. Amir Kalbasi
- Univ: Amirkabir University of Technology - Tehran Polytechnic
- Semester: Fall 1400
The exercise and report documents are available in docs
branch.
View the Exercise PDF.
View the Report PDF.
Licensed under MIT.