改名
This commit is contained in:
@@ -13,6 +13,7 @@ class Constant
|
||||
|
||||
const START = 'Start';
|
||||
const SHUTDOWN = 'Shutdown';
|
||||
const BEFORE_SHUTDOWN = 'beforeShutdown';
|
||||
const WORKER_START = 'WorkerStart';
|
||||
const WORKER_STOP = 'WorkerStop';
|
||||
const WORKER_EXIT = 'WorkerExit';
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Server\Events;
|
||||
|
||||
use Swoole\Server;
|
||||
|
||||
class OnBeforeShutdown
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param Server|null $server
|
||||
*/
|
||||
public function __construct(?Server $server = null)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,11 +3,12 @@
|
||||
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;
|
||||
use Server\Abstracts\Server;
|
||||
use Server\Events\OnBeforeShutdown;
|
||||
use Server\Events\OnShutdown;
|
||||
use Server\Events\OnStart;
|
||||
|
||||
|
||||
/**
|
||||
@@ -36,6 +37,14 @@ class OnServer extends Server
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param \Swoole\Server $server
|
||||
*/
|
||||
public function onBeforeShutdown(\Swoole\Server $server)
|
||||
{
|
||||
$this->eventDispatch->dispatch(new OnBeforeShutdown($server));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param \Swoole\Server $server
|
||||
@@ -46,5 +55,4 @@ class OnServer extends Server
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Server\SInterface;
|
||||
|
||||
interface OnBeforeShutdown
|
||||
{
|
||||
|
||||
}
|
||||
@@ -14,13 +14,13 @@ use Server\Manager\OnPipeMessage;
|
||||
use Server\Manager\OnServer;
|
||||
use Server\Manager\OnServerManager;
|
||||
use Server\Manager\OnServerReload;
|
||||
use Server\SInterface\OnProcessInterface;
|
||||
use Server\SInterface\OnCloseInterface;
|
||||
use Server\SInterface\OnConnectInterface;
|
||||
use Server\SInterface\OnDisconnectInterface;
|
||||
use Server\SInterface\OnHandshakeInterface;
|
||||
use Server\SInterface\OnMessageInterface;
|
||||
use Server\SInterface\OnPacketInterface;
|
||||
use Server\SInterface\OnProcessInterface;
|
||||
use Server\SInterface\OnReceiveInterface;
|
||||
use Server\SInterface\OnTaskInterface;
|
||||
use Server\Task\OnServerTask;
|
||||
@@ -71,11 +71,11 @@ class ServerManager
|
||||
Constant::BEFORE_RELOAD => [OnServerReload::class, 'onBeforeReload'],
|
||||
Constant::AFTER_RELOAD => [OnServerReload::class, 'onAfterReload'],
|
||||
Constant::START => [OnServer::class, 'onStart'],
|
||||
Constant::BEFORE_SHUTDOWN => [OnServer::class, 'onBeforeShutdown'],
|
||||
Constant::SHUTDOWN => [OnServer::class, 'onShutdown'],
|
||||
];
|
||||
|
||||
|
||||
|
||||
private array $eventInterface = [
|
||||
OnReceiveInterface::class => 'receive',
|
||||
OnPacketInterface::class => 'packet',
|
||||
@@ -87,7 +87,6 @@ class ServerManager
|
||||
];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return Server|WServer|HServer|null
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user