I am using BROADCAST_DRIVER=redis to trigger laravel 5.2 event. Once i run the following services on command prompt :
In the first tab, run node socket.js
You should see "Listening on Port 3000"
In the second tab run redis-server --port 3001
After it Open up two browser windows side by side and in the first one hit the URL: "http://your-project-name.app/fire"
And in the second: "http://your-project-name.app/test"
Keep refreshing the first window and you should see the second page's content updated.
But i do not want to refreshing the page , i just want to trigger the broadcast event in background and also do not want to run the services "node socket.js and redis-server --port 3004".
I have installed node,redis,express ioredis socket.io and created the event.
My socket code:
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var Redis = require('ioredis');
var redis = new Redis();
redis.subscribe('test-channel', function(err, count) { });
redis.on('message', function(channel, message) {
console.log('Message Recieved: ' + message);
message = JSON.parse(message);
io.emit(channel + ':' + message.event, message.data);
});
http.listen(3004, function(){
console.log('Listening on Port 3004');
});