This commit is contained in:
2020-09-04 00:41:33 +08:00
parent 622071256e
commit 46f9de1f6a
141 changed files with 105 additions and 73 deletions
+64
View File
@@ -0,0 +1,64 @@
<?php
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 $Message = 'required|not empty';
private $Handshake;
private $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;
}
}