Last active
August 29, 2015 13:57
-
-
Save jasonpincin/9613792 to your computer and use it in GitHub Desktop.
rpc client using dnode, shoe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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