Lots of frame stubs
This commit is contained in:
48
src/Http2Middleware.php
Normal file
48
src/Http2Middleware.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\React\Http2;
|
||||
|
||||
use NoccyLabs\React\Http2\Connection\Http2Connection;
|
||||
use NoccyLabs\React\Http2\Frame\SettingsFrame;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use React\Stream\DuplexResourceStream;
|
||||
use React\Stream\DuplexStreamInterface;
|
||||
use React\Stream\ThroughStream;
|
||||
use SplObjectStorage;
|
||||
|
||||
class Http2Middleware
|
||||
{
|
||||
/** @var SplObjectStorage<Http2Connection> Active connections */
|
||||
private SplObjectStorage $connections;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->connections = new SplObjectStorage();
|
||||
}
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, ?callable $next=null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function parseSettingsFromBase64String(string $settings): SettingsFrame
|
||||
{
|
||||
$decoded = base64_decode($settings);
|
||||
$frame = new SettingsFrame();
|
||||
$frame->parseFrame($decoded);
|
||||
return $frame;
|
||||
}
|
||||
|
||||
private function setupConnection(ServerRequestInterface $request): Http2Connection
|
||||
{
|
||||
$stream = new ThroughStream();
|
||||
$connection = new Http2Connection($stream);
|
||||
|
||||
$this->connections->attach($connection);
|
||||
$connection->on('close', function () use ($connection) {
|
||||
$this->connections->detach($connection);
|
||||
});
|
||||
|
||||
return $connection;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user