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');