Files
kiri-core/system/Annotation/Definition/Websocket.php
T

60 lines
883 B
PHP
Raw Normal View History

2020-08-31 01:27:08 +08:00
<?php
2020-08-31 23:28:17 +08:00
namespace Snowflake\Annotation\Definition;
2020-08-31 01:27:08 +08:00
use ReflectionClass;
2020-08-31 23:28:17 +08:00
use Snowflake\Annotation\Annotation;
2020-08-31 01:27:08 +08:00
/**
* Class Websocket
* @package Snowflake\Annotation
*/
class Websocket extends Annotation
{
2020-08-31 22:33:50 +08:00
const WEBSOCKET_ANNOTATION = 'WEBSOCKET:ANNOTATION:';
2020-08-31 01:27:08 +08:00
2020-08-31 22:33:50 +08:00
private $Message = 'required|not empty';
2020-08-31 01:27:08 +08:00
2020-08-31 22:33:50 +08:00
private $Handshake;
private $Close;
2020-08-31 01:27:08 +08:00
/**
2020-08-31 22:33:50 +08:00
* @param $controller
* @param $methodName
* @param $events
* @return array
2020-08-31 01:27:08 +08:00
*/
2020-08-31 22:33:50 +08:00
public function createHandler($controller, $methodName, $events)
2020-08-31 01:27:08 +08:00
{
2020-08-31 22:33:50 +08:00
return [$controller, $methodName];
2020-08-31 01:27:08 +08:00
}
2020-08-31 22:33:50 +08:00
2020-08-31 23:30:32 +08:00
public function isLegitimate($events)
{
return true;
}
2020-08-31 01:27:08 +08:00
/**
* @param $events
* @param $comment
* @return false|string
*/
2020-08-31 22:33:50 +08:00
public function getName($events, $comment)
2020-08-31 01:27:08 +08:00
{
2020-08-31 22:33:50 +08:00
$prefix = self::WEBSOCKET_ANNOTATION . $events;
if (isset($comment[2])) {
return $prefix . ':' . $comment[2];
2020-08-31 01:27:08 +08:00
}
2020-08-31 22:33:50 +08:00
return $prefix;
2020-08-31 01:27:08 +08:00
}
}