This commit is contained in:
as2252258@163.com
2021-09-24 02:04:36 +08:00
parent 318fe08eb5
commit b9a1178fbe
10 changed files with 168 additions and 237 deletions
+36 -2
View File
@@ -4,17 +4,51 @@ namespace Server\Service;
use Kiri\Abstracts\Config;
use Kiri\Exception\ConfigException;
use Kiri\Kiri;
use Server\Abstracts\Server;
use Server\Abstracts\Utility\EventDispatchHelper;
use Server\Abstracts\Utility\ResponseHelper;
use Server\Constrict\UdpEmitter;
use Server\ExceptionHandlerDispatcher;
use Server\ExceptionHandlerInterface;
use Server\SInterface\OnPacket;
/**
*
*/
class Udp extends \Server\Abstracts\Udp
class Udp implements OnPacket
{
use EventDispatchHelper;
use ResponseHelper;
/**
/**
* @var ExceptionHandlerInterface
*/
public ExceptionHandlerInterface $exceptionHandler;
/**
* @throws ConfigException
*/
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);
$this->responseEmitter = Kiri::getDi()->get(UdpEmitter::class);
}
/**
* @param Server $server
* @param string $data
* @param array $clientInfo