Guest User

Untitled

a guest
Jan 14th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. var connect = require('connect'),
  2. app = connect.createServer(connect.static(__dirname)),
  3. io = require('socket.io').listen(app),
  4. port = process.env.PORT || 80
  5. ;
  6.  
  7. app.listen(port);
  8.  
  9. io.configure(function(){
  10. io.enable('browser client minification'); // send minified client
  11. io.enable('browser client etag'); // apply etag caching logic based on version number
  12. // io.set('log level', 1); // reduce logging
  13. io.set("transports", ["xhr-polling"]);
  14. io.set("polling duration", 10);
  15. });
  16.  
  17. io.sockets.on('connection', function (socket) {
  18. console.log("connection established!");
  19.  
  20. //socket.on('my other event', function (data) {
  21. // console.log("DATA:"+data);
  22. //});
  23.  
  24. socket.emit('news', { hello: 'world' }, function(data) {
  25. console.log("received:"+data);
  26. });
  27. });
Add Comment
Please, Sign In to add comment