furality / socket.io-php-emitter
PHP socket.io event emitter
Installs: 1 143
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 9
Open Issues: 2
Requires
- php: ^8.1
- predis/predis: ^1.1
- rybakit/msgpack: ^0.9.1
Requires (Dev)
- mockery/mockery: ^1.5
- phpspec/prophecy-phpunit: ^2.0
- phpstan/extension-installer: ^1.1.0
- phpunit/php-code-coverage: ^9.2
- phpunit/phpunit: ^9
This package is not auto-updated.
Last update: 2024-11-04 05:46:34 UTC
README
A PHP implementation of node.js socket.io-emitter.
Installation
composer require Furality/socket.io-php-emitter
Usage
Emit payload message
use Predis\Client; use Furality\SocketIO\Emitter; ... $client = new Client(); (new Emitter($client)) ->of('namespace')->emit('event', 'payload message');
Flags
Possible flags
- json
- volatile
- broadcast
To use flags, just call it like in examples bellow
use Predis\Client; use Furality\SocketIO\Emitter; ... $client = new Client(); (new Emitter($client)) ->broadcast->emit('broadcast-event', 'payload message'); (new Emitter($client)) ->flag('broadcast')->emit('broadcast-event', 'payload message');
Emit an object
use Predis\Client; use Furality\SocketIO\Emitter; ... $client = new Client(); (new Emitter($client)) ->emit('broadcast-event', ['param1' => 'value1', 'param2' => 'value2', ]);
Emit an object in multiple rooms
use Predis\Client; use Furality\SocketIO\Emitter; ... $client = new Client(); (new Emitter($client)) ->in(['room1', 'room2']) ->emit('broadcast-event', ['param1' => 'value1', 'param2' => 'value2', ]);
Credits
This library is forked from shakahl/socket.io-emitter created by Soma Szélpál.
The shakahl/socket.io-emitter is forked from exls/socket.io-emitter created by Anton Pavlov.