This commit is contained in:
2021-08-12 14:08:40 +08:00
parent 3bd3a39642
commit 14cb8a45d3
12 changed files with 152 additions and 21 deletions
+15 -5
View File
@@ -6,7 +6,11 @@ use Annotation\Inject;
use Exception;
use Server\Abstracts\Server;
use Server\Constant;
use Server\Events\OnAfterReload;
use Server\Events\OnAfterRequest;
use Server\Events\OnBeforeReload;
use Server\Events\OnShutdown;
use Server\Events\OnStart;
use Server\SInterface\PipeMessage;
use Kiri\Event;
use Kiri\Events\EventDispatch;
@@ -20,8 +24,14 @@ use Kiri\Exception\ConfigException;
class OnServerDefault extends Server
{
/**
* @var EventDispatch
*/
#[Inject(EventDispatch::class)]
public EventDispatch $eventDispatch;
/**
/**
* @param \Swoole\Server $server
* @throws ConfigException
*/
@@ -29,7 +39,7 @@ class OnServerDefault extends Server
{
$this->setProcessName(sprintf('start[%d].server', $server->master_pid));
$this->runEvent(Constant::START, null, [$server]);
$this->eventDispatch->dispatch(new OnStart($server));
}
@@ -38,7 +48,7 @@ class OnServerDefault extends Server
*/
public function onShutdown(\Swoole\Server $server)
{
$this->runEvent(Constant::SHUTDOWN, null, [$server]);
$this->eventDispatch->dispatch(new OnShutdown($server));
}
@@ -48,7 +58,7 @@ class OnServerDefault extends Server
*/
public function onBeforeReload(\Swoole\Server $server)
{
$this->runEvent(Constant::BEFORE_RELOAD, null, [$server]);
$this->eventDispatch->dispatch(new OnBeforeReload($server));
}
@@ -57,7 +67,7 @@ class OnServerDefault extends Server
*/
public function onAfterReload(\Swoole\Server $server)
{
$this->runEvent(Constant::AFTER_RELOAD, null, [$server]);
$this->eventDispatch->dispatch(new OnAfterReload($server));
}
}