Files
kiri-core/Server/Abstracts/Udp.php
T

48 lines
986 B
PHP
Raw Normal View History

2021-08-12 12:40:06 +08:00
<?php
namespace Server\Abstracts;
use Kiri\Abstracts\Config;
use Kiri\Exception\ConfigException;
use Kiri\Exception\NotFindClassException;
use Kiri\Kiri;
use ReflectionException;
use Server\ExceptionHandlerDispatcher;
use Server\ExceptionHandlerInterface;
use Server\SInterface\OnPacket;
use Server\SInterface\OnReceive;
2021-08-12 14:00:44 +08:00
/**
*
*/
abstract class Udp extends Server implements OnPacket
2021-08-12 12:40:06 +08:00
{
use EventDispatchHelper;
use ResponseHelper;
/**
* @var ExceptionHandlerInterface
*/
public ExceptionHandlerInterface $exceptionHandler;
/**
* @throws ReflectionException
* @throws ConfigException
* @throws NotFindClassException
*/
public function init()
{
$exceptionHandler = Config::get('exception.udp', ExceptionHandlerDispatcher::class);
if (!in_array(ExceptionHandlerInterface::class, class_implements($exceptionHandler))) {
$exceptionHandler = ExceptionHandlerDispatcher::class;
}
$this->exceptionHandler = Kiri::getDi()->get($exceptionHandler);
}
}