mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
wip
This commit is contained in:
@@ -35,14 +35,14 @@ class ConnectionManager implements ConnectionManagerContract
|
||||
return $storedConnection;
|
||||
}
|
||||
|
||||
public function storeHttpConnection(ConnectionInterface $httpConnection, $requestId): ConnectionInterface
|
||||
public function storeHttpConnection(ConnectionInterface $httpConnection, $requestId): HttpConnection
|
||||
{
|
||||
$this->httpConnections[$requestId] = $httpConnection;
|
||||
$this->httpConnections[$requestId] = new HttpConnection($httpConnection);
|
||||
|
||||
return $httpConnection;
|
||||
return $this->httpConnections[$requestId];
|
||||
}
|
||||
|
||||
public function getHttpConnectionForRequestId(string $requestId): ?ConnectionInterface
|
||||
public function getHttpConnectionForRequestId(string $requestId): ?HttpConnection
|
||||
{
|
||||
return $this->httpConnections[$requestId] ?? null;
|
||||
}
|
||||
|
||||
32
app/Server/Connections/HttpConnection.php
Normal file
32
app/Server/Connections/HttpConnection.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Server\Connections;
|
||||
|
||||
use Evenement\EventEmitterTrait;
|
||||
use Ratchet\ConnectionInterface;
|
||||
|
||||
class HttpConnection
|
||||
{
|
||||
use EventEmitterTrait;
|
||||
|
||||
/** @var ConnectionInterface */
|
||||
public $socket;
|
||||
|
||||
public function __construct(ConnectionInterface $socket)
|
||||
{
|
||||
$this->socket = $socket;
|
||||
}
|
||||
|
||||
public function send($data)
|
||||
{
|
||||
$this->emit('data', [$data]);
|
||||
$this->socket->send($data);
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
$this->emit('close');
|
||||
|
||||
$this->socket->close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user