Skip to content

Instantly share code, notes, and snippets.

@memorycraft
Last active December 12, 2015 06:38
Show Gist options
  • Save memorycraft/4730182 to your computer and use it in GitHub Desktop.
Save memorycraft/4730182 to your computer and use it in GitHub Desktop.
var io = require('socket.io').listen(3000);
var RedisStore = require('socket.io/lib/stores/redis');
opts = {host:'xxx.xxx.xxx.xxx', port:6379};
io.set('store', new RedisStore({redisPub:opts, redisSub:opts, redisClient:opts}));
io.sockets.on('connection', function (socket) {
socket.emit('info', { msg: 'welcome' });
socket.on('msg', function (msg) {
io.sockets.emit('msg', {msg: msg});
});
socket.on('disconnect', function(){
socket.emit('info', {msg: 'bye'});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment