Skip to content

Instantly share code, notes, and snippets.

@timoxley
Created January 21, 2012 04:47
Show Gist options
  • Save timoxley/1651328 to your computer and use it in GitHub Desktop.
Save timoxley/1651328 to your computer and use it in GitHub Desktop.
dnode-web-test
<html>
<head>
<script src="/dnode.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function () {
DNode.connect(function (remote) {
remote.cat(function (says) {
document.getElementById('says').innerHTML = says;
});
});
};
</script>
</head>
<body>
The cat says <span id="says">?</span>.
</body>
</html>
var connect = require('connect');
var dnode = require('dnode');
var server = connect.createServer();
server.use(connect.static(__dirname));
dnode(function (client) {
this.cat = function (cb) {
cb('meow ');
};
}).listen(server).listen(6857);
console.log('http://localhost:6857/');
var client = dnode.connect('6857', function() {
console.log('connected. calling remote.cat')
remote.cat(function(value) {
console.log(value)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment