Skip to content

Instantly share code, notes, and snippets.

@dgershman
Created June 27, 2012 14:24
Show Gist options
  • Save dgershman/3004373 to your computer and use it in GitHub Desktop.
Save dgershman/3004373 to your computer and use it in GitHub Desktop.
Node Server - RAPJS
io.sockets.on('connection', function(socket) {
const redisQueue = redis.createClient(port, hostname);
redisQueue.subscribe('reporting');
socket.emit('connected', "connected to the server" );
count++;
socket.emit('real-action', getVisitEvent(count));
socket.on('disconnect', function() {
count--;
socket.emit('real-action', getVisitEvent(count));
});
redisQueue.on("message", function(channel, message) {
socket.emit('recv-action', message );
});
setInterval(function() {
socket.emit('real-action', getVisitEvent(count));
}, 1200);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment