<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ruslanmelnychenko / socket.io-php-emitter example snippets
use RuslanMelnychenko\SocketIO\Emitter;
...
$client = new \Redis();
(new Emitter($client))
->of('namespace')->emit('event', 'payload message');
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);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.