how to create separate events in socket io with laravel

  laravel, real-time, redis, sockets

I want to create multi events in socket io with redis this is my code

***
var redisClient =  redis.createClient(6379, "127.0.0.1");
redisClient.on('connect', function() {
    console.log('we are connected with redis server')
});
redisClient.subscribe('message','call','status');
redisClient.on("message", function(channel, message) {
    var data = JSON.parse(message);
    console.log("new message in queue " + "channel : " + channel + " reciever: " + message);
    io.in(data.receiver_id).emit("message", message);
});
redisClient.on("call", function(channel, call) {
    var data = JSON.parse(call);
    console.log("new call in queue " + "channel : " + channel + " reciever: " + call);
    io.in(data.receiver_id).emit("call", call);
});
redisClient.on("status", function(channel, status) {
    var data = JSON.parse(status);
    console.log("new status in queue " + "channel : " + channel + " reciever: " + status);
    io.in(data.receiver_id).emit("status", status);
});***

first one message event created and others created inside the message event

Source: Laravel

Leave a Reply