This commit is contained in:
2021-08-04 14:45:50 +08:00
parent f112b19d8f
commit 07e3f3f1e3
2 changed files with 0 additions and 68 deletions
-45
View File
@@ -1,45 +0,0 @@
<?php
namespace Annotation;
use Exception;
use Snowflake\Snowflake;
/**
* Class Port
* @package Annotation
*/
#[\Attribute(\Attribute::TARGET_CLASS)] class Port extends Attribute
{
/**
* Port constructor.
* @param int $port
* @param int $mode
*/
public function __construct(public int $port, public int $mode = SWOOLE_SOCK_TCP)
{
}
/**
* @param mixed $class
* @param mixed|null $method
* @return mixed
* @throws Exception
*/
public function execute(mixed $class, mixed $method = null): mixed
{
$router = Snowflake::app()->getRouter();
if (!($class instanceof Porters)) {
return true;
}
$router->addPortListen($this->port, [$class, 'process']);
return true;
}
}