This commit is contained in:
2021-08-12 14:35:28 +08:00
parent d814603118
commit cb1e59cdcf
2 changed files with 45 additions and 25 deletions
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace Server\Manager;
use Annotation\Inject;
use Server\Abstracts\Server;
use Server\Events\OnShutdown;
use Server\Events\OnStart;
use Kiri\Events\EventDispatch;
use Kiri\Exception\ConfigException;
/**
* Class OnServerDefault
* @package Server\Manager
*/
class OnServer extends Server
{
/**
* @var EventDispatch
*/
#[Inject(EventDispatch::class)]
public EventDispatch $eventDispatch;
/**
* @param \Swoole\Server $server
* @throws ConfigException
*/
public function onStart(\Swoole\Server $server)
{
$this->setProcessName(sprintf('start[%d].server', $server->master_pid));
$this->eventDispatch->dispatch(new OnStart($server));
}
/**
* @param \Swoole\Server $server
*/
public function onShutdown(\Swoole\Server $server)
{
$this->eventDispatch->dispatch(new OnShutdown($server));
}
}