Files
kiri-core/HttpServer/Route/Annotation/Websocket.php
T
2020-10-29 18:17:25 +08:00

66 lines
1021 B
PHP

<?php
declare(strict_types=1);
namespace HttpServer\Route\Annotation;
use Snowflake\Annotation\Annotation;
/**
* Class Websocket
* @package Snowflake\Annotation
*/
class Websocket extends Annotation
{
const MESSAGE = 'Message';
const HANDSHAKE = 'Handshake';
const CLOSE = 'Close';
private string $Message = 'required|not empty';
private string $Handshake;
private string $Close;
/**
* @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 = 'WEBSOCKET:ANNOTATION:' . ltrim($events, ':');
if (isset($comment[2]) && !empty($comment[2])) {
return $prefix . ':' . $comment[2];
}
return $prefix;
}
}