Try use Elephant
This might also help you. http://stackoverflow.com/questions/6398887/using-php-with-socket-io
So you should end up with something like this, you want to emit after your queue job is done using Laravel's Events or something.
var server = require('http').createServer(),
io = require('socket.io')(server);
io.on('connection', function (socket) {
socket.on('broadcast', function (message) {
// {foo: 'bar'}
// You can then emit message back to subscriber
});
};
server.listen(1337);
use ElephantIO\Client;
use ElephantIO\Engine\SocketIO\Version1X;
require __DIR__ . '/../../../../vendor/autoload.php';
$client = new Client(new Version1X('http://localhost:1337'));
$client->initialize();
$client->emit('broadcast', ['foo' => 'bar']);
$client->close();
Hope it helps!
Hello @awsp Thanks for your code sharing. I read some tutorials and documentation from socket.io and redis and in the end I understood how it works.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community