This commit is contained in:
2020-12-14 19:11:51 +08:00
parent 627bfab070
commit 6e6daaa3cf
2 changed files with 24 additions and 2 deletions
+21
View File
@@ -4,6 +4,11 @@
namespace Annotation;
use Closure;
use HttpServer\Route\Node;
use Snowflake\Exception\ComponentException;
use Snowflake\Snowflake;
/**
* Class Socket
* @package Annotation
@@ -28,4 +33,20 @@ namespace Annotation;
{
}
/**
* @param Closure|array $closure
* @return mixed
* @throws ComponentException
*/
public function setHandler(Closure|array $closure): mixed
{
$router = Snowflake::app()->getRouter();
// TODO: Implement setHandler() method.
$method = $this->event . '::' . ($this->uri ?? 'event');
return $router->addRoute($method, $closure, 'sw::socket');
}
}