Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. var app = require('http');
  2. function handler(req, res){
  3. fs.readFile('./public/index.html',function(err,data){
  4. res.writeHead(200);
  5. res.end(data);
  6. });
  7. }
  8. var o=app.createServer(handler);
  9. var io = require('socket.io').listen(app);
  10. var fs = require('fs');
  11.  
  12. o.listen(4000);
  13.  
  14. io.sockets.on('connection', function(socket){
  15. socket.emit('news',{hello:'world'});
  16. socket.on('my other event',function(data){
  17. console.log(data);
  18. });
  19. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement