From c337ad99a41c28db5affbd63482f650cbe642867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 1 Apr 2021 11:28:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Events/OnPacket.php | 4 +++- HttpServer/Events/OnReceive.php | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/HttpServer/Events/OnPacket.php b/HttpServer/Events/OnPacket.php index b4aa3d79..987710ee 100644 --- a/HttpServer/Events/OnPacket.php +++ b/HttpServer/Events/OnPacket.php @@ -47,7 +47,9 @@ class OnPacket extends Callback $dispatch = $node->dispatch(); if (!is_string($dispatch)) $dispatch = Json::encode($dispatch); - + if (empty($dispatch)) { + return true; + } return $server->sendto($host, $port, $dispatch); } catch (\Throwable $exception) { $this->addError($exception, 'packet'); diff --git a/HttpServer/Events/OnReceive.php b/HttpServer/Events/OnReceive.php index 16a7b738..5c74d36a 100644 --- a/HttpServer/Events/OnReceive.php +++ b/HttpServer/Events/OnReceive.php @@ -41,10 +41,11 @@ class OnReceive extends Callback if (($node = $router->find_path($request)) === null) { return $server->send($fd, Json::encode(['state' => 404])); } - $dispatch = $node->dispatch(); if (!is_string($dispatch)) $dispatch = Json::encode($dispatch); - + if (empty($dispatch)) { + return true; + } return $server->send($fd, $dispatch); } catch (\Throwable $exception) { $this->addError($exception, 'receive');