This commit is contained in:
2022-01-09 03:49:02 +08:00
parent b5ad99332d
commit 550197de96
44 changed files with 2113 additions and 2113 deletions
+62 -62
View File
@@ -1,62 +1,62 @@
<?php
namespace Server\Handler;
use Kiri\Annotation\Inject;
use Kiri\Events\EventDispatch;
use Kiri\Exception\ConfigException;
use ReflectionException;
use Server\Abstracts\Server;
use Server\Events\OnBeforeShutdown;
use Server\Events\OnShutdown;
use Server\Events\OnStart;
/**
* Class OnServerDefault
* @package Server\Manager
*/
class OnServer extends Server
{
/**
* @var EventDispatch
*/
#[Inject(EventDispatch::class)]
public EventDispatch $eventDispatch;
/**
* @param \Swoole\Server $server
* @throws ConfigException
* @throws ReflectionException
*/
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
* @throws ReflectionException
*/
public function onBeforeShutdown(\Swoole\Server $server)
{
$this->eventDispatch->dispatch(new OnBeforeShutdown($server));
}
/**
* @param \Swoole\Server $server
* @throws ReflectionException
*/
public function onShutdown(\Swoole\Server $server)
{
$this->eventDispatch->dispatch(new OnShutdown($server));
}
}
<?php
namespace Server\Handler;
use Kiri\Annotation\Inject;
use Kiri\Events\EventDispatch;
use Kiri\Exception\ConfigException;
use ReflectionException;
use Server\Abstracts\Server;
use Server\Events\OnBeforeShutdown;
use Server\Events\OnShutdown;
use Server\Events\OnStart;
/**
* Class OnServerDefault
* @package Server\Manager
*/
class OnServer extends Server
{
/**
* @var EventDispatch
*/
#[Inject(EventDispatch::class)]
public EventDispatch $eventDispatch;
/**
* @param \Swoole\Server $server
* @throws ConfigException
* @throws ReflectionException
*/
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
* @throws ReflectionException
*/
public function onBeforeShutdown(\Swoole\Server $server)
{
$this->eventDispatch->dispatch(new OnBeforeShutdown($server));
}
/**
* @param \Swoole\Server $server
* @throws ReflectionException
*/
public function onShutdown(\Swoole\Server $server)
{
$this->eventDispatch->dispatch(new OnShutdown($server));
}
}