Skip to content

Commit

Permalink
Adicionado arquivo socke.js
Browse files Browse the repository at this point in the history
  • Loading branch information
vluzrmos committed May 9, 2015
1 parent a1d8664 commit d3844ec
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/Vluzrmos/Socketio/socket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var app = require('express');
var http = require('http').Server(app);
var io = require('socket.io')(http);
var Redis = require('ioredis');

/*
* Your Redis connection
* @see https://www.npmjs.com/package/ioredis for more details
*/
var redis = new Redis('redis://127.0.0.1:6379/0');

/**
* Your broadcasting channel
*/
redis.subscribe('channel', function(err, count){

});

/*
* Your broadcasting emitter
*/
redis.on('message', function(channel, message){
message = JSON.parse(message);

io.emit(channel+':'+message.event, message.payload);
});

/*
* http server listen 8080
*/
http.listen(8080, function(){
console.log('Listen on 0.0.0.0:8080');
});

0 comments on commit d3844ec

Please sign in to comment.