peter ed3da909c6 push | il y a 5 ans | |
---|---|---|
src | il y a 5 ans | |
test | il y a 5 ans | |
.drone.yml | il y a 5 ans | |
.gitignore | il y a 5 ans | |
.npmignore | il y a 5 ans | |
README.md | il y a 5 ans | |
package-lock.json | il y a 5 ans | |
package.json | il y a 5 ans | |
tsconfig.json | il y a 5 ans |
rpclibrary is a websocket on steroids!
npm i rpclibrary
import {Backend, Frontend} from 'rpclibrary'
const echo = (x) => x
const server = new Backend.RPCServer(20000, [{
name: 'HelloWorldRPCGroup',
exportRPCs: () => [
echo,
function echof(x){ return x },
{
name: 'echoExplicit',
call: async (x) => x
}
]
}])
const client = new Frontend.RPCSocket(20000, 'localhost')
client.connect().then(async () => {
const r0 = await client['HelloWorldRPCGroup'].echo('Hello')
const r1 = await client['HelloWorldRPCGroup'].echof('World')
const r2 = await client['HelloWorldRPCGroup'].echoExplicit('RPC!')
console.log(r0,r1,r2)
})