Files
kiri-core/HttpServer/Route/Annotation/Websocket.php
T

65 lines
975 B
PHP
Raw Normal View History

2020-08-31 01:27:08 +08:00
<?php
2020-09-01 03:11:34 +08:00
namespace HttpServer\Route\Annotation;
2020-08-31 01:27:08 +08:00
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-09-01 04:35:14 +08:00
const MESSAGE = 'Message';
const HANDSHAKE = 'Handshake';
const CLOSE = 'Close';
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:32:25 +08:00
/**
* @param $events
* @return bool|void
*/
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-09-01 04:24:36 +08:00
public function getName($events, $comment = [])
2020-08-31 01:27:08 +08:00
{
2020-09-01 04:33:57 +08:00
$prefix = 'WEBSOCKET:ANNOTATION:' . ltrim($events, ':');
if (isset($comment[2]) && !empty($comment[2])) {
2020-09-01 04:15:23 +08:00
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
}
}