A PHP implementation of node.js socket.io-emitter. Use PhpRedis client.
composer require ruslanmelnychenko/socket.io-php-emitter
use RuslanMelnychenko\SocketIO\Emitter;
...
$client = new \Redis();
(new Emitter($client))
->of('namespace')->emit('event', 'payload message');
Possible flags
- json
- volatile
- broadcast
use RuslanMelnychenko\SocketIO\Emitter;
...
$client = new \Redis();
$client->connect('127.0.0.1');
(new Emitter($client))
->broadcast->emit('broadcast-event', 'payload message');
(new Emitter($client))
->flag('broadcast')->emit('broadcast-event', 'payload message');
use RuslanMelnychenko\SocketIO\Emitter;
...
$client = new \Redis();
$client->connect('127.0.0.1');
(new Emitter($client))
->emit('broadcast-event', ['param1' => 'value1', 'param2' => 'value2', ]);
use RuslanMelnychenko\SocketIO\Emitter;
...
$client = new \Redis();
$client->connect('127.0.0.1');
(new Emitter($client))
->in(['room1', 'room2'])
->emit('broadcast-event', ['param1' => 'value1', 'param2' => 'value2', ]);
use RuslanMelnychenko\SocketIO\Emitter;
...
$client = new \Redis();
$client->connect('127.0.0.1');
(new Emitter($client))
->in(['room1', 'room2'])
->except(['room3'])
->emit('broadcast-event', ['param1' => 'value1', 'param2' => 'value2', ]);
use RuslanMelnychenko\SocketIO\Emitter;
...
$client = new \Redis();
$client->connect('127.0.0.1');
(new Emitter($client))
->in(['room1', 'room2'])
->except(['room3'])
->socketsJoin('room4');
(new Emitter($client))
->in(['room4'])
->socketsLeave('room3');
(new Emitter($client))
->in(['room1'])
->disconnectSockets();
(new Emitter($client))
->of('/tasks')
->serverSideEmit('taskDone', 1);