mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-15 06:25:56 +00:00
wip
This commit is contained in:
@@ -82,7 +82,20 @@ class ConnectionManager implements ConnectionManagerContract
|
|||||||
|
|
||||||
protected function getSharedTcpServer(): Server
|
protected function getSharedTcpServer(): Server
|
||||||
{
|
{
|
||||||
return new Server(0, $this->loop);
|
$portRange = [50000, 62000];
|
||||||
|
$port = $portRange[0];
|
||||||
|
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
$portFound = true;
|
||||||
|
$server = new Server('127.0.0.1:'.$port, $this->loop);
|
||||||
|
} catch (\RuntimeException $exception) {
|
||||||
|
$portFound = false;
|
||||||
|
$port++;
|
||||||
|
}
|
||||||
|
} while(! $portFound);
|
||||||
|
|
||||||
|
return $server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function storeHttpConnection(ConnectionInterface $httpConnection, $requestId): HttpConnection
|
public function storeHttpConnection(ConnectionInterface $httpConnection, $requestId): HttpConnection
|
||||||
@@ -107,6 +120,16 @@ class ConnectionManager implements ConnectionManagerContract
|
|||||||
|
|
||||||
if (isset($connection->client_id)) {
|
if (isset($connection->client_id)) {
|
||||||
$clientId = $connection->client_id;
|
$clientId = $connection->client_id;
|
||||||
|
|
||||||
|
$controlConnection = collect($this->connections)->first(function ($connection) use ($clientId) {
|
||||||
|
return $connection->client_id == $clientId;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($controlConnection instanceof TcpControlConnection) {
|
||||||
|
$controlConnection->stop();
|
||||||
|
$controlConnection = null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->connections = collect($this->connections)->reject(function ($connection) use ($clientId) {
|
$this->connections = collect($this->connections)->reject(function ($connection) use ($clientId) {
|
||||||
return $connection->client_id == $clientId;
|
return $connection->client_id == $clientId;
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ class TcpControlConnection extends ControlConnection
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function stop()
|
||||||
|
{
|
||||||
|
$this->shared_server->close();
|
||||||
|
$this->shared_server = null;
|
||||||
|
}
|
||||||
|
|
||||||
public function close()
|
public function close()
|
||||||
{
|
{
|
||||||
$this->socket->close();
|
$this->socket->close();
|
||||||
|
|||||||
Reference in New Issue
Block a user