2017 © Pedro Peláez
 

library socketio-emitter

image

valeriitropin/socketio-emitter

  • Monday, December 18, 2017
  • by valeriitropin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PHP socket.io emitter

Async implementation of socket.io emitter written in php. Built on top of ReactPHP components., (*1)

Installation

composer require valeriitropin/socketio-emitter

How to use

use React\EventLoop\Factory as ReactFactory;
use ValeriiTropin\Socketio\Emitter;

$loop = ReactFactory::create();
$emitter = new Emitter($loop);

$promise = $emitter->to($room)->emit($event, $data)
    ->then(function () {})
    ->otherwise(function ($error) {});

API

Emitter

__construct(React\EventLoop\LoopInterface $loop, $options = [], ValeriiTropin\Socketio\PackerInterface $packer = null)

$options:
  • key: pub/sub events prefix (socket.io)
  • namespace: socket.io namespace (/)
  • uri: Redis connection string, see docs (localhost)
  • client: pub client

to($room): ValeriiTropin\Socketio\Emitter

Adds room and returns current Emitter instance, (*2)

$emitter->to($room);

of($namespace): ValeriiTropin\Socketio\Emitter

Creates new Emitter instance with given namespace., (*3)

$emitter->of($namespace);

emit($event, ...$args): React\Promise\Promise

Emits event with data to set rooms., (*4)

$emitter->emit($event, $data)
    ->then(function () {})
    ->otherwise(function ($error) {});

getLoop(): React\EventLoop\LoopInterface

Returns loop instance., (*5)

The Versions

18/12 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Valerii Tropin

redis emitter socket.io

18/12 2017

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

by Valerii Tropin

redis emitter socket.io