Guest User

server

a guest
Jun 4th, 2013
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. var app = require('http').createServer(handler)
  2. , io = require('socket.io').listen(app)
  3. , fs = require('fs')
  4.  
  5. app.listen(88);
  6.  
  7. var texto = 'AAA';
  8.  
  9. function handler (req, res) {
  10. fs.readFile(__dirname + '/index.html',
  11. function (err, data) {
  12. if (err) {
  13. res.writeHead(500);
  14. return res.end('Error loading index.html');
  15. }
  16.  
  17. res.writeHead(200);
  18. res.end(data);
  19. });
  20. }
  21.  
  22. io.sockets.on('connection', function (socket) {
  23.  
  24. socket.on('Text', function(data) {
  25.  
  26. socket.emit('add', data);
  27.  
  28. });
  29.  
  30. socket.on('disconnect', function () {
  31.  
  32. io.sockets.emit(' USER DISCONNECT ');
  33.  
  34. });
  35.  
  36. });
Advertisement
Add Comment
Please, Sign In to add comment