A PHP implementation of socket.io-emitter.
This project uses msgpack-php and phpredis. Make sure to have those extensions in use before trying to use the emitter.
To install and use in your PHP project, just use this as a composer package (will be available soon).
To run tests, invoke make test
.
<?php
$redis = new \Redis();
$redis->connect('127.0.0.1', '6379');
$emitter = new SocketIO\Emitter($redis);
$emitter->emit('event', 'payload str');
?>
<?php
$emitter = new SocketIO\Emitter(array('port' => '6379', 'host' => '127.0.0.1'));
$emitter->emit('event', 'wow');
?>
Possible flags
- json
- volatile
- broadcast
<?php
$emitter = new SocketIO\Emitter(array('port' => '6379', 'host' => '127.0.0.1'));
// broadcast can be replaced by any of the other flags
$emitter->broadcast->emit('other event', 'such data');
?>
<?php
$emitter = new SocketIO\Emitter(array('port' => '6379', 'host' => '127.0.0.1'));
$binarydata = pack("nvc*", 0x1234, 0x5678, 65, 66);
$emitter->emit('very', new SocketIO\Binary($binarydata));
?>