ekstazi / websocket-common-amphp
amphp/websocket adapter implementation for stream interfaces
2.1.1
2020-04-10 12:26 UTC
Requires
- php: >=7.2
- amphp/websocket: ^1.0@RC
- ekstazi/websocket-common: ^2.0
Requires (Dev)
- amphp/php-cs-fixer-config: dev-master
- amphp/phpunit-util: ^1.1
- phpunit/phpunit: ^8 || ^7
README
ekstazi/websocket-common-amphp
is amphp/websocket
adapter to amphp streams. This package is internally used in ekstazi/websocket-stream-client-amphp
Installation
This package can be installed as a Composer dependency.
composer require ekstazi/websocket-common-amphp
Requirements
PHP 7.2+
Usage
<?php use ekstazi\websocket\common\amphp\Reader; use ekstazi\websocket\common\amphp\Connection; use ekstazi\websocket\common\amphp\Writer; /** @var \Amp\Websocket\Client $client */ $stream = new Connection(new Reader($client), new Writer($client)); $stream->setDefaultMode(Writer::MODE_TEXT); // alternative way to create stream // $stream = Connection::create($client, Writer::MODE_TEXT); yield $stream->read(); yield $stream->write('test');