clutch-rpc

ClutchRPC - GRPC For The Browser And Node.

Usage no npm install needed!

<script type="module">
  import clutchRpc from 'https://cdn.skypack.dev/clutch-rpc';
</script>

README

ClutchRPC

npm npm NPM

Logo

ClutchRPC - GRPC For The Browser And Node.

NPM

Installation

npm i clutch-rpc  

Usage

Server


const ClutchRPC = require('clutch-rpc')
 
const server = new ClutchRPC.Server('http://localhost:3000/')

server.on('connection', (client) => {

    console.log('Client Connected')

    client.send('Hello, Client')
        //==> Send Mesage To Client

    client.on('message', (message) => {

        console.log('Incoming Message: ', message)

    })
    
})

server.on('disconnect', () => {

    console.log('Client Disconnected')

})

Client


const ClutchRPC = require('clutch-rpc')
 
const client = new ClutchRPC('http://localhost:3000/')

console.log('Connected')

client.send('Hello, Server')
    //==> Send Mesage To Server

client.on('message', (message) => {

    console.log('Incoming Message: ', message)

})

client.on('disconnect', () => {

    console.log('Disconnected')
    
})

Browser

Proxy

const ClutchRPC = require('clutch-rpc')

const server = new ClutchRPC.webServer({
    clutch_uri: 'http://localhost:3000',
    proxy_uri: 'http://localhost:5000'
})

Browser

<script src="https://unpkg.com/clutch-rpc@latest/browser.min.js">
const client = new ClutchRPC('http://localhost:5000/')
//==> Connect To Proxy/Server

console.log('Connected')

client.send('Hello, Server')
    //==> Send Mesage To Server Via Proxy To localhost:3000

client.on('message', (message) => {

    console.log('Incoming Message: ', message)

})

client.on('disconnect', () => {

    console.log('Disconnected')
    
})