Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var connect = require('connect'),
- app = connect.createServer(connect.static(__dirname)),
- io = require('socket.io').listen(app),
- port = process.env.PORT || 80
- ;
- app.listen(port);
- io.configure(function(){
- io.enable('browser client minification'); // send minified client
- io.enable('browser client etag'); // apply etag caching logic based on version number
- // io.set('log level', 1); // reduce logging
- io.set("transports", ["xhr-polling"]);
- io.set("polling duration", 10);
- });
- io.sockets.on('connection', function (socket) {
- console.log("connection established!");
- //socket.on('my other event', function (data) {
- // console.log("DATA:"+data);
- //});
- socket.emit('news', { hello: 'world' }, function(data) {
- console.log("received:"+data);
- });
- });
Add Comment
Please, Sign In to add comment