heapwolf/node-chrome

what's the next step?

sequoiar opened this issue · 3 comments

any ideas on RPC API between Node.js and Chrome for node-chrome?

I'd recommend https://github.com/substack/dnode

I generally avoid it for websites as it's fairly high bandwidth and difficult to do authentication over, but it should be perfect for a situation like this where you have plenty of bandwidth, low latency, and no real security concerns.

It essentially lets you call arbitrary functions over a socket.io connection and pass functions to be used as callbacks.

Right now the way i use it is by having a simple json-based agreement.

Client Side

Each outgoing message from the browser has this structure { request: 'nameOfRequest', body: 'value' }. Each incoming request to the browser gets parsed and i have a switch statement to parse the request.

Server Side

Each outgoing response from the server has this structure { response: 'nameOfRequest', body: 'value' }. Each incoming request to the server gets parsed and i also have a switch statement for that which also maps to a function/controller for processing.

This keeps things lite as far as machinery for processing/routing messages. I would absolutely accept a pull request that used dnode that has a intuitive API.

See #6 for a solution that would enable people to choose their transport protocol independently of node-chrome.