Skip to content

Commit e033ad5

Browse files
committed
emit to any channel, subscribe to another example.
1 parent 18b6087 commit e033ad5

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>This is an amazing fake app right?</h2>
1212
<script>
1313
var socket = io();
1414

15-
socket.on('new app version', function(msg){
15+
socket.on('frontend-app-version', function(msg){
1616
$('#versions').append($('<li>').text(msg));
1717
});
1818
</script>

server.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ var redisClient = redis.createClient();
99
var socketIORedis = require('socket.io-redis');
1010
io.adapter(socketIORedis({ host: 'localhost', port: 6379 }));
1111

12-
redisClient.subscribe('new-app-version');
12+
redisClient.subscribe('frontend-app-version');
13+
redisClient.subscribe('iphone-app-version');
1314

1415
redisClient.on('message', function(channel, message) {
15-
if(channel == 'new-app-version') {
16-
io.emit('new app version', message);
17-
}
16+
io.emit(channel, message);
1817
});
1918

2019
// server config
@@ -24,6 +23,6 @@ app.get('/', function (req, res) {
2423

2524
http.listen(3000, function(){
2625
console.log('listening on *:3000');
27-
console.log('publish something to the new-app-version Redis channel (redis-cli publish new-app-version whoa!)');
26+
console.log('publish something to the new-app-version Redis channel (redis-cli publish frontend-app-version whoa!)');
2827
console.log('---');
2928
});

0 commit comments

Comments
 (0)