real-share
v2.0.2
Published
Call a remote function or method of a remote object from a Node.js App thru websocket that can be shared to any web frontend frameworks or mobile apps
Downloads
12
Maintainers
Readme
Welcome to real-share!
Directly call a function or method of a remote object from a Node.js App thru websocket that can be shared to any web frontend frameworks or mobile apps.
Installation
npm install real-share
or
yarn add real-share
CDN
<script src="https://unpkg.com/real-share/client.js"></script>
Server
// Server.js
const realShare = require('real-share/server')
class Person {
constructor() {
this.name = 'Trinmar Pogi'
}
run(speed, client) {
console.log(client.id)
return `${this.name} is running at ${speed}km/h`
}
eat(food) {
return `${this.name} is eating ${food}`
}
async talk(speech) {
await new Promise(r => setTimeout(r, 2000))
return speech
}
}
let human = new Person('Trinmar Pogi')
realShare(3000, {
human
})
Client
async function init () {
const realShare = require('real-share/client')
// for CDN global variable named 'realShare'
const { human } = await realShare('http://localhost:3131')
console.log(await human.run(100)) // Mr. Pogi is running at 100km/h
}
init()
Join and support our Community
Web and Mobile Developers PH
[ Facebook Page | Group ]