npm.io
0.1.4 • Published 13 years ago

rpc-duplex-node

Licence
—
Version
0.1.4
Deps
2
Vulns
4
Weekly
0

###rpc-duplex-node
Simple rpc for node/express. Uses websocket if browser supported, else polling.

Like this..

###app.js

	var express = require('express'), app = express();
	var server = require('http').createServer(app)
 	server.listen(85);


 	var allin = require('./rpc-duplex-node.js')(app);
 	allin.log = console.log;

 	// Send some calls to the clients using clientcall()
 	function doit(){
 		allin.clientcall('document.getElementById("timeis").innerHTML=new Date()')
 	}
 	setInterval(doit, 1000);


 	app.get('/', function(r,s){
 		s.sendfile('index.html')
 	})

###index.html

<!-- include the script -->
<script src='/rpc'></script>

<div id='timeis'/>

Keywords