ekstazi / websocket-stream-client-pawl
ratchet/pawl adapter implementation for websocket stream client.
2.0.1
2020-04-10 14:29 UTC
Requires
- php: >=7.2
- amphp/react-adapter: ^2.1
- ekstazi/websocket-stream-client: ^2.0
- psr/container: ^1.0
- ratchet/pawl: dev-drain-event-support
Requires (Dev)
- amphp/php-cs-fixer-config: dev-master
- amphp/phpunit-util: ^1.1
- phpunit/phpunit: ^8 || ^7
Provides
This package is auto-updated.
Last update: 2024-10-11 00:28:03 UTC
README
ekstazi/websocket-stream-client-pawl
is ekstazi/websocket-stream-client
implementation based on ratchet/pawl
Installation
This package can be installed as a Composer dependency.
composer require ekstazi/websocket-stream-client-pawl
Requirements
PHP 7.2+
Usage
With container
If you have container then add this to your container.php
use \ekstazi\websocket\client\pawl\ConnectorFactory; use \ekstazi\websocket\client\ConnectionFactory; // .... return [ ConnectionFactory::class => new ConnectorFactory(), ];
Then in your code:
use \Psr\Container\ContainerInterface; use \ekstazi\websocket\client\ConnectionFactory; use \Psr\Http\Message\RequestInterface; use \ekstazi\websocket\client\Connection; /** @var ContainerInterface $container */ /** @var ConnectionFactory $connector */ /** @var RequestInterface $request */ $connector = $container->get(ConnectionFactory::class); /** @var Connection $stream */ $stream = yield $connector->connect($request, Connection::MODE_BINARY);
Without container
You can use functions to do the same:
use \ekstazi\websocket\client\ConnectionFactory; use \Psr\Http\Message\RequestInterface; use \ekstazi\websocket\client\Connection; use function \ekstazi\websocket\client\connect; /** @var RequestInterface $request */ /** @var Connection $stream */ $stream = yield connect($request, Connection::MODE_BINARY);
or
use \ekstazi\websocket\client\ConnectionFactory; use \Psr\Http\Message\RequestInterface; use \ekstazi\websocket\client\Connection; use function \ekstazi\websocket\client\connector; /** @var RequestInterface $request */ /** @var ConnectionFactory $connector */ $connector = connector(); /** @var Connection $stream */ $stream = yield $connector->connect($request, Connection::MODE_BINARY);