Skip to content

Instantly share code, notes, and snippets.

@jasonpincin
Last active August 29, 2015 13:57
Show Gist options
  • Save jasonpincin/9613792 to your computer and use it in GitHub Desktop.
Save jasonpincin/9613792 to your computer and use it in GitHub Desktop.
rpc client using dnode, shoe
var shoe = require('shoe')
var dnode = require('dnode')
var document = require('global/document')
var onTime = function (err, time) {
document.getElementById('time').innerHTML = time
}
var onSquare = function (err, val) {
document.getElementById('square').innerHTML = val
}
var socket = shoe('/socket')
var d = dnode()
d.on('remote', function (server) {
var nextNum = 1
var everySecond = function () {
server.getTime(onTime)
server.square(++nextNum, onSquare)
}
setInterval(everySecond, 1000)
})
socket.pipe(d).pipe(socket)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment