modify plugin name

This commit is contained in:
2022-02-16 10:55:42 +08:00
parent 8cd3886494
commit 2d0f214a9f
2 changed files with 64 additions and 72 deletions
+18 -3
View File
@@ -4,12 +4,14 @@ namespace Kiri\Websocket;
use Kiri;
use Swoole\{Coroutine\Http\Server as AliasServer, WebSocket\Server};
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
*
*/
class Sender implements WebSocketInterface
class Sender extends Kiri\Abstracts\Component implements WebSocketInterface
{
@@ -19,6 +21,20 @@ class Sender implements WebSocketInterface
private AliasServer|Server|null $server = null;
private FdCollector $collector;
/**
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function init()
{
$this->collector = $this->getContainer()->get(FdCollector::class);
}
/**
* @param AliasServer|Server $server
*/
@@ -43,9 +59,8 @@ class Sender implements WebSocketInterface
if ($this->server instanceof Server) {
return $this->server->push($fd, $data, $opcode, $flags);
}
$collector = Kiri::getContainer()->get(FdCollector::class);
$response = $collector->get($fd);
$response = $this->collector->get($fd);
if (!empty($response)) {
return $response->push($data, $opcode, $flags);
}