1. Go to this page and download the library: Download ekstazi/async-binary-stream library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ekstazi / async-binary-stream example snippets
use \ekstazi\stream\binary\ByteReader;
use \Amp\ByteStream\InputStream;
use \PHPinnacle\Buffer\ByteBuffer;
/** @var InputStream $inputStream */
$reader = new ByteReader($inputStream);
/** @var ByteBuffer $buffer */
$buffer = yield $reader->readBytes(4);
$opCode = $buffer->consumeInt16();
$mask = $buffer->consumeInt16();
use \ekstazi\stream\binary\ByteWriter;
use \Amp\ByteStream\OutputStream;
use \PHPinnacle\Buffer\ByteBuffer;
$opCode = 2;
$mask = 1;
/** @var OutputStream $outputStream */
$writer = new ByteWriter($outputStream);
/** @var ByteBuffer $buffer */
$buffer = new ByteBuffer();
$buffer->appendInt16($opCode);
$buffer->appendInt16($mask);
yield $writer->writeBytes($buffer);
use \ekstazi\stream\binary\ByteReader;
use \ekstazi\stream\binary\ByteRecorder;
use \Amp\ByteStream\InputStream;
use \PHPinnacle\Buffer\ByteBuffer;
/** @var InputStream $inputStream */
$reader = new ByteReader($inputStream);
$recorder = new ByteRecorder($reader);
$recorder->startRecord();
/** @var ByteBuffer $buffer */
$buffer = yield $recorder->readBytes(4);
$opCode = $buffer->consumeInt16();
$mask = $buffer->consumeInt16();
// ....
$buffer = yield $recorder->readBytes(12);
// ....
/** @var ByteBuffer $recorded The data recorded after startRecord */
$recorded = $recorder->stopRecord();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.