I'm receiving a message on redis and I'm trying to emit it using below node code on a server:
var server = require('http').Server();
var io = require('socket.io')(server);
var Redis = require('ioredis');
var redis = new Redis();
redis.subscribe('test-channel', function() {
console.log('I just subscribed to channel waiting for messages ...');
});
redis.on('message', function(channel, message){
message = JSON.parse(message);
console.log(channel, message);
io.emit(channel + ':' + message.event, message.data);
// another test emit
io.emit('test', 'hi!');
});
server.listen(3500);
And this is my client side code responsible for getting messages:
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.7/socket.io.min.js"></script>
var socket = io('http://localhost:3500');
socket.on('test-channel:App\\Events\\PacketArrived', function (data){
console.log('yes! I got it!');
console.log(data);
});
socket.on('test', function (data){
console.log('yes! I got it!');
console.log(data);
} );
I get the log for redis.on('message' ... part but unfortunately, I'm not getting anything on client-side socket logs. I don't get any error messages to debug.