http.createServer(function(req, res){ if (gun.wsp.server(req, res)) { return; // filters gun requests! } fs.createReadStream(path.join(__dirname, req.url)) .on('error', function() { // static files! res.writeHead(200, {'Content-Type': 'text/html'}); res.end(fs.readFileSync(path.join(__dirname, 'index.html'))); // or default to index }).pipe(res); // stream })
setTimeout(function(){ // access the data as if it is a document. gun.get('mark').get('boss').get('name').val(function(data, key){ // `val` grabs the data once, no subscriptions. console.log("Mark's boss is", data); }); }, 5000);
setTimeout(function(){ // access the data as if it is a document. gun.get('mark').get('boss').get('name').val(function(data, key){ // `val` grabs the data once, no subscriptions. console.log("Mark's boss is", data); }); }, 10000);