-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); |