2020-09-02 11:38:47 +08:00
|
|
|
<?php
|
2020-10-29 18:17:25 +08:00
|
|
|
declare(strict_types=1);
|
2020-09-02 11:38:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace HttpServer\Route\Annotation;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Snowflake\Annotation\Annotation;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Tcp
|
|
|
|
|
* @package HttpServer\Route\Annotation
|
|
|
|
|
*/
|
|
|
|
|
class Tcp extends Annotation
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CONNECT = 'Connect';
|
|
|
|
|
const PACKET = 'Packet';
|
|
|
|
|
const RECEIVE = 'Receive';
|
|
|
|
|
const CLOSE = 'Close';
|
|
|
|
|
|
2020-10-29 18:17:25 +08:00
|
|
|
private string $Message = 'required|not empty';
|
2020-09-02 11:38:47 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $controller
|
|
|
|
|
* @param $methodName
|
|
|
|
|
* @param $events
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function createHandler($controller, $methodName, $events)
|
|
|
|
|
{
|
|
|
|
|
return [$controller, $methodName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $events
|
|
|
|
|
* @return bool|void
|
|
|
|
|
*/
|
|
|
|
|
public function isLegitimate($events)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $events
|
|
|
|
|
* @param $comment
|
|
|
|
|
* @return false|string
|
|
|
|
|
*/
|
|
|
|
|
public function getName($events, $comment = [])
|
|
|
|
|
{
|
|
|
|
|
$prefix = 'TCP:ANNOTATION:' . ltrim($events, ':');
|
|
|
|
|
if (isset($comment[2]) && !empty($comment[2])) {
|
|
|
|
|
return $prefix . ':' . $comment[2];
|
|
|
|
|
}
|
|
|
|
|
return $prefix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|