Files
kiri-core/Server/Manager/ServerDefaultEvent.php
T

71 lines
1.3 KiB
PHP
Raw Normal View History

2021-07-18 12:06:56 +08:00
<?php
namespace Server\Manager;
2021-07-19 19:04:13 +08:00
use Server\Abstracts\Server;
use Server\Constant;
2021-07-23 17:12:20 +08:00
use Server\SInterface\PipeMessage;
2021-07-19 19:04:13 +08:00
/**
2021-07-23 17:12:20 +08:00
* Class ServerDefaultEvent
2021-07-19 19:04:13 +08:00
* @package Server\Manager
*/
2021-07-23 17:12:20 +08:00
class ServerDefaultEvent extends Server
2021-07-18 12:06:56 +08:00
{
2021-07-19 19:04:13 +08:00
/**
* @param \Swoole\Server $server
*/
public function onStart(\Swoole\Server $server)
2021-07-18 12:06:56 +08:00
{
2021-07-19 19:04:13 +08:00
$this->runEvent(Constant::START, null, [$server]);
2021-07-18 12:06:56 +08:00
}
2021-07-19 19:04:13 +08:00
/**
* @param \Swoole\Server $server
*/
public function onShutdown(\Swoole\Server $server)
2021-07-18 12:06:56 +08:00
{
2021-07-19 19:04:13 +08:00
$this->runEvent(Constant::SHUTDOWN, null, [$server]);
2021-07-18 12:06:56 +08:00
}
2021-07-19 19:04:13 +08:00
/**
* @param \Swoole\Server $server
* @param int $src_worker_id
* @param mixed $message
*/
public function onPipeMessage(\Swoole\Server $server, int $src_worker_id, mixed $message)
2021-07-18 12:06:56 +08:00
{
2021-07-23 17:12:20 +08:00
if (is_null($message = unserialize($message))) {
return;
}
if (!is_object($message) || !($message instanceof PipeMessage)) {
return;
}
2021-07-19 19:04:13 +08:00
$this->runEvent(Constant::PIPE_MESSAGE, null, [$server, $src_worker_id, $message]);
2021-07-18 12:06:56 +08:00
}
2021-07-19 19:04:13 +08:00
/**
* @param \Swoole\Server $server
*/
public function onBeforeReload(\Swoole\Server $server)
2021-07-18 12:06:56 +08:00
{
2021-07-23 17:12:20 +08:00
$this->runEvent(Constant::BEFORE_RELOAD, null, [$server]);
2021-07-18 12:06:56 +08:00
}
2021-07-19 19:04:13 +08:00
/**
* @param \Swoole\Server $server
*/
public function onAfterReload(\Swoole\Server $server)
2021-07-18 12:06:56 +08:00
{
2021-07-23 17:12:20 +08:00
$this->runEvent(Constant::AFTER_RELOAD, null, [$server]);
2021-07-18 12:06:56 +08:00
}
}