Skip to content

Instantly share code, notes, and snippets.

@rabc
Created May 13, 2014 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rabc/0a73df2ccfafdb6b5255 to your computer and use it in GitHub Desktop.
Save rabc/0a73df2ccfafdb6b5255 to your computer and use it in GitHub Desktop.
var express = require('express'),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
port = 8080;
server.listen(port);
// it's here to serve my static content (js, css, etc)
var oneDay = 86400000;
app.use(express.static(__dirname, {maxAge: oneDay}));
io.sockets.on('connection', function(socket) {
enviaFila();
// other stuffs...
});
function enviaFila() {
// my stuff...
io.sockets.emit('fila', {message: 'my message'});
}
@julianduque
Copy link

io.sockets.on('connection', function (socket) { 
  enviaFila(socket);
});

......

function enviaFila(socket) { 
  socket.emit('fila', { message: 'my message' });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment