How to serve client-js from push-it using node.js
I have just started using node.js. My mayor problem is lack of documentation but I'm getting throug开发者_如何学运维h and I really like it
Now I'm trying to use push-it which sits on top of socket.io. The Docs mention to serve the static client-js file, but I don't know how to do that. I already tried different paths. Socket.io works out of the box, but I can't find how to do it for push-it.
I installed push-it using npm
Thanks for any tips, Miguel
you can use connect or express to server static files,
exactly as the dnode docs suggest.
__dirname is the directory you're running from, it's common to use __dirname + '/public' and place your files in there
var connect = require('connect');
var server = connect.createServer();
server.use(connect.staticProvider(__dirname));
var dnode = require('dnode');
dnode(function (client) {
this.cat = function (cb) {
cb('meow');
};
}).listen(server);
精彩评论