shakahl / socket.io-php-emitter
PHP socket.io event emitter
Installs: 10 316
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 9
Open Issues: 1
Requires
- php: >=5.6.4
- predis/predis: ^1.0
- rybakit/msgpack: ^0.1.0
This package is not auto-updated.
Last update: 2024-12-21 21:52:40 UTC
README
A PHP implementation of node.js socket.io-emitter (0.1.0).
Installation
composer require shakahl/socket.io-php-emitter
Usage
Emit payload message
use Predis; use Shakahl\SocketIO; ... $client = new Predis\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; use Shakahl\SocketIO; ... $client = new Predis\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; use Shakahl\SocketIO; ... $client = new Predis\Client(); (new Emitter($client)) ->emit('broadcast-event', ['param1' => 'value1', 'param2' => 'value2', ]);
Emit an object in a rooms
use Predis; use Shakahl\SocketIO; ... $client = new Predis\Client(); (new Emitter($client)) ->in(['room1', 'room2']) ->emit('broadcast-event', ['param1' => 'value1', 'param2' => 'value2', ]);
Credits
This library is forked from exls/socket.io-emitter created by Anton Pavlov.