New file |
| | |
| | | <?php |
| | | /* |
| | | * @Author: your name |
| | | * @Date: 2021-12-24 10:26:10 |
| | | * @LastEditTime: 2021-12-24 17:21:42 |
| | | * @LastEditors: Please set LastEditors |
| | | * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE |
| | | * @FilePath: /hy-websocket/app/Controller/WebsocketController.php |
| | | */ |
| | | |
| | | declare(strict_types=1); |
| | | |
| | | namespace App\Controller; |
| | | |
| | | use Hyperf\Contract\OnCloseInterface; |
| | | use Hyperf\Contract\OnMessageInterface; |
| | | use Hyperf\Contract\OnOpenInterface; |
| | | use Swoole\Http\Request; |
| | | use Swoole\Http\Response; |
| | | use Swoole\WebSocket\Frame; |
| | | use Swoole\WebSocket\Server; |
| | | use Hyperf\Di\Annotation\Inject; |
| | | use App\Service\TransferService; |
| | | use Hyperf\Logger\LoggerFactory; |
| | | use Hyperf\Contract\ConfigInterface; |
| | | |
| | | class WebsocketController implements OnMessageInterface, OnOpenInterface, OnCloseInterface |
| | | { |
| | | /** |
| | | * @Inject |
| | | * @var TransferService |
| | | */ |
| | | private $transferService; |
| | | /** |
| | | * |
| | | * @var \Psr\Log\LoggerInterface |
| | | */ |
| | | public $logger; |
| | | |
| | | /** |
| | | * @Inject() |
| | | * @var ConfigInterface |
| | | */ |
| | | private $config; |
| | | |
| | | private $server_config; |
| | | |
| | | private $allow_ip; |
| | | |
| | | public function __construct(LoggerFactory $loggerFactory) |
| | | { |
| | | // 第一个参数对应日志的 name, 第二个参数对应 config/autoload/logger.php 内的 key |
| | | $this->logger = $loggerFactory->get('log','default'); |
| | | //获取 server.php 里的内容 |
| | | $this->server_config = $this->config->get('server.servers',''); |
| | | $this->allow_ip = $this->server_config[0]['allow_ip']; |
| | | } |
| | | |
| | | public function onClose($server, int $fd, int $reactorId): void |
| | | { |
| | | //客户端异常关闭 |
| | | //语音文件传输完毕,关闭文件。 |
| | | $host = $this->allow_ip; |
| | | $group_key = $this->transferService->get($host.':'.$fd.':group'); |
| | | $this->transferService->lrem($group_key,$fd,0); |
| | | $set_ket = $host.':'.$fd.':group'; |
| | | $this->transferService->delete($set_ket); |
| | | } |
| | | |
| | | public function onStart($server): void |
| | | { |
| | | $host = $this->allow_ip; |
| | | $keyList = $this->transferService->keys("*{$host}*"); |
| | | foreach ($keyList as $key => $value) { |
| | | $this->transferService->delete($value); |
| | | } |
| | | } |
| | | /** |
| | | * @param Response|Server $server |
| | | */ |
| | | public function onMessage($server, Frame $frame): void |
| | | { |
| | | $ret = array('code' => 0, 'data' => null); |
| | | $msgData = $this->is_json($frame->data,true); |
| | | if($msgData){ |
| | | $frameData = $msgData; |
| | | $url = $frameData['url']; |
| | | $data = $frameData['data']; |
| | | $action = substr($url, strrpos($url, "/") + 1); |
| | | switch ($action) |
| | | { |
| | | case "reg": |
| | | $groupId = $data['group_id']; |
| | | $session = $data['session_id']; |
| | | $this->bind($groupId,'',$frame->fd); |
| | | $key = "practice_scenes_ws_cur_session_info:".$session; |
| | | $node_key = 'practice_scenes_ws_cur_session_node_info:'.$session; |
| | | $redisData = $this->transferService->get($key); |
| | | if($redisData){ |
| | | $ret['data'] =json_decode($redisData,true); |
| | | $this->transferService->delete($key); |
| | | }else{ |
| | | $redisData = $this->transferService->get($node_key); |
| | | if($redisData){ |
| | | $ret['data'] = json_decode($redisData,true); |
| | | }else{ |
| | | $ret['data'] = ''; |
| | | } |
| | | } |
| | | $ret['event'] = "re_bind"; |
| | | $server->push($frame->fd, json_encode($ret)); |
| | | break; |
| | | case "data": |
| | | $groupId = $data['group_id']; |
| | | $ret['event'] = "data"; |
| | | $ret['data'] = $data; |
| | | $connections = array(); |
| | | if(empty($groupId)){ |
| | | // 获取所有无分组标识在线终端 |
| | | $onlines = count($server->connections); |
| | | if ($onlines > 0) { |
| | | $connections = $server->connections; |
| | | } |
| | | }else{ |
| | | // 获取所有分组标识在线终端 key = groupID:host |
| | | $key = $groupId . ':' . $this->allow_ip; |
| | | $connections = $this->transferService->lrange($key, 0, -1); |
| | | } |
| | | $connections = array_unique($connections); |
| | | // 广播获取的在线终端 |
| | | foreach ($connections as $fd) { |
| | | $ingfd = (int)$fd; |
| | | $server->push($ingfd,json_encode($ret)); |
| | | } |
| | | break; |
| | | case "ping": |
| | | $server->push($frame->fd, $data.'pong'); |
| | | break; |
| | | default: |
| | | $ret['code'] = 404; |
| | | $ret['msg'] = 'event no existent'; |
| | | $server->push($frame->fd,json_encode($ret)); |
| | | return; |
| | | } |
| | | }else{ |
| | | $ret['code'] = -1; |
| | | $ret['msg'] = 'data is null or data no json'; |
| | | $server->push($frame->fd, json_encode($ret)); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | public function onOpen($server, Request $request): void |
| | | { |
| | | // $server->push($request->fd, 'Opened'); |
| | | // var_dump($request); |
| | | } |
| | | |
| | | /** |
| | | * 功能:1、判断是否是json |
| | | * @param string $data |
| | | * @param bool $assoc |
| | | * @return bool|mixed|string |
| | | */ |
| | | public function is_json($data = '', $assoc = false) |
| | | { |
| | | $data = json_decode($data, $assoc); |
| | | if ($data && (is_object($data)) || (is_array($data) && ! empty(current($data)))) { |
| | | return $data; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 当前链接的绑定事件。 |
| | | * 绑定的几种状态: |
| | | * 1.无分组 |
| | | * host -> fds (获取当前节点的在线链接列表) |
| | | * host:fd -> value (获取当前节点当前链接的绑定数据) |
| | | * host:fd:group -> host (获取当前节点当前链接的绑定分组) |
| | | * 2.有分组 |
| | | * groupID:host -> fds |
| | | * host:fd -> value |
| | | * host:fd:group -> groupID:host |
| | | * @param string $groupID 需要绑定当前链接所在分组的分组标识,如果为空则使用默认分组 |
| | | * @param string $value 需要绑定当前链接对应的业务数据,如果为空则不绑定 |
| | | */ |
| | | public function bind($groupID = '', $value = '',$fd){ |
| | | $host = $this->allow_ip; |
| | | // 绑定分组和当前链接对应的分组标识 |
| | | if(empty($groupID)){ |
| | | $this->transferService->rpush($host, $fd); |
| | | $this->transferService->set($host.':'.$fd.':group', $host); |
| | | }else{ |
| | | $this->transferService->rpush($groupID.':'.$host, $fd); |
| | | $this->transferService->set($host.':'.$fd.':group', $groupID.':'.$host); |
| | | } |
| | | // 绑定业务数据 |
| | | if(!empty($value)){ |
| | | $this->transferService->set($host.':'.$fd, $value); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | namespace App\Exception\Handler; |
| | | |
| | | use Hyperf\Contract\StdoutLoggerInterface; |
| | | use Hyperf\ExceptionHandler\ExceptionHandler; |
| | | use Hyperf\HttpMessage\Stream\SwooleStream; |
| | | use Psr\Http\Message\ResponseInterface; |
| | | use Throwable; |
| | | |
| | | class AppExceptionHandler extends ExceptionHandler |
| | | { |
| | | /** |
| | | * @var StdoutLoggerInterface |
| | | */ |
| | | protected $logger; |
| | | |
| | | public function __construct(StdoutLoggerInterface $logger) |
| | | { |
| | | $this->logger = $logger; |
| | | } |
| | | |
| | | public function handle(Throwable $throwable, ResponseInterface $response) |
| | | { |
| | | $this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); |
| | | $this->logger->error($throwable->getTraceAsString()); |
| | | return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.')); |
| | | } |
| | | |
| | | public function isValid(Throwable $throwable): bool |
| | | { |
| | | return true; |
| | | } |
| | | } |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | namespace App\Listener; |
| | | |
| | | use Hyperf\Database\Events\QueryExecuted; |
| | | use Hyperf\Event\Annotation\Listener; |
| | | use Hyperf\Event\Contract\ListenerInterface; |
| | | use Hyperf\Logger\LoggerFactory; |
| | | use Hyperf\Utils\Arr; |
| | | use Hyperf\Utils\Str; |
| | | use Psr\Container\ContainerInterface; |
| | | use Psr\Log\LoggerInterface; |
| | | |
| | | /** |
| | | * @Listener |
| | | */ |
| | | class DbQueryExecutedListener implements ListenerInterface |
| | | { |
| | | /** |
| | | * @var LoggerInterface |
| | | */ |
| | | private $logger; |
| | | |
| | | public function __construct(ContainerInterface $container) |
| | | { |
| | | $this->logger = $container->get(LoggerFactory::class)->get('sql'); |
| | | } |
| | | |
| | | public function listen(): array |
| | | { |
| | | return [ |
| | | QueryExecuted::class, |
| | | ]; |
| | | } |
| | | |
| | | /** |
| | | * @param QueryExecuted $event |
| | | */ |
| | | public function process(object $event) |
| | | { |
| | | if ($event instanceof QueryExecuted) { |
| | | $sql = $event->sql; |
| | | if (! Arr::isAssoc($event->bindings)) { |
| | | foreach ($event->bindings as $key => $value) { |
| | | $sql = Str::replaceFirst('?', "'{$value}'", $sql); |
| | | } |
| | | } |
| | | |
| | | $this->logger->info(sprintf('[%s] %s', $event->time, $sql)); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | namespace App\Model; |
| | | |
| | | use Hyperf\DbConnection\Model\Model as BaseModel; |
| | | |
| | | abstract class Model extends BaseModel |
| | | { |
| | | } |
New file |
| | |
| | | <?php |
| | | namespace App\Service; |
| | | use Hyperf\Redis\Redis; |
| | | use Hyperf\Di\Annotation\Inject; |
| | | use Hyperf\Config\Annotation\Value; |
| | | |
| | | use App\Utils\Http; |
| | | |
| | | class TransferService extends Http |
| | | { |
| | | /** |
| | | * |
| | | * @Inject |
| | | * @var Redis |
| | | */ |
| | | private $redis; |
| | | |
| | | public function ping() |
| | | { |
| | | $result=$this->redis->ping(); |
| | | } |
| | | |
| | | public function setnx($strKey,$value) |
| | | { |
| | | $this->redis->setnx($strKey,$value); |
| | | } |
| | | |
| | | public function set($strKey,$value) |
| | | { |
| | | $this->redis->set($strKey,$value); |
| | | } |
| | | |
| | | public function get($strKey) |
| | | { |
| | | return $this->redis->get($strKey); |
| | | } |
| | | |
| | | public function delete($strKey) |
| | | { |
| | | $this->redis->del($strKey); |
| | | } |
| | | |
| | | public function incrby($str_key,$value=0){ |
| | | $this->redis->incrby($str_key,$value); |
| | | } |
| | | |
| | | public function incr($fd){ |
| | | return $this->redis->incr($fd); |
| | | } |
| | | |
| | | public function decr($strKey) |
| | | { |
| | | return $this->redis->decr($strKey); |
| | | } |
| | | |
| | | public function decrby($strKey,$num) |
| | | { |
| | | return $this->redis->decrby($strKey,$num); |
| | | } |
| | | |
| | | public function lSize($strKey) |
| | | { |
| | | return $this->redis->lSize($strKey); |
| | | } |
| | | |
| | | public function lGet($strKey,$index) |
| | | { |
| | | return $this->redis->lGet($strKey,$index); |
| | | } |
| | | |
| | | public function lrem($strKey,$value,$index) |
| | | { |
| | | return $this->redis->lrem($strKey,$value,$index); |
| | | } |
| | | |
| | | public function lPush($strKey,$value) |
| | | { |
| | | $this->redis->lPush($strKey,$value); |
| | | } |
| | | |
| | | public function rPush($strKey,$value) |
| | | { |
| | | $this->redis->rPush($strKey,$value); |
| | | } |
| | | |
| | | public function lPop($strKey) |
| | | { |
| | | return $this->redis->lPop($strKey); |
| | | } |
| | | |
| | | public function rPop($strKey) |
| | | { |
| | | return $this->redis->rPop($strKey); |
| | | } |
| | | |
| | | public function lSet($strKey,$index,$value) |
| | | { |
| | | return $this->redis->lSet($strKey,$index,$value); |
| | | } |
| | | |
| | | public function lrange($strKey,$index,$length) |
| | | { |
| | | return $this->redis->lrange($strKey,$index,$length); |
| | | } |
| | | |
| | | public function keys($strKey) |
| | | { |
| | | return $this->redis->keys($strKey); |
| | | } |
| | | } |
New file |
| | |
| | | <?php |
| | | |
| | | /* |
| | | * To change this license header, choose License Headers in Project Properties. |
| | | * To change this template file, choose Tools | Templates |
| | | * and open the template in the editor. |
| | | */ |
| | | namespace App\Utils; |
| | | |
| | | class HashMap |
| | | { |
| | | var $m_table; |
| | | |
| | | |
| | | public function __construct() |
| | | { |
| | | $this->m_table = array (); |
| | | } |
| | | |
| | | public function put($key, $value) |
| | | { |
| | | if (!array_key_exists($key, $this->m_table)) |
| | | { |
| | | $this->m_table[$key] = $value; |
| | | return null; |
| | | } |
| | | else |
| | | { |
| | | $tempValue = $this->m_table[$key]; |
| | | $this->m_table[$key] = $value; |
| | | return $tempValue; |
| | | } |
| | | } |
| | | |
| | | |
| | | public function get($key) |
| | | { |
| | | if (array_key_exists($key, $this->m_table)) |
| | | return $this->m_table[$key]; |
| | | return null; |
| | | } |
| | | |
| | | public function remove($key) |
| | | { |
| | | if(array_key_exists($key, $this->m_table)) |
| | | { |
| | | unset($this->m_table[$key]); |
| | | } |
| | | return $this->m_table; |
| | | } |
| | | |
| | | public function keys() |
| | | { |
| | | return array_keys($this->m_table); |
| | | } |
| | | |
| | | public function values() |
| | | { |
| | | return array_values($this->m_table); |
| | | } |
| | | |
| | | public function put_all($map) |
| | | { |
| | | if(!$map->isEmpty()&& $map->size()>0) |
| | | { |
| | | $keys = $map->keys(); |
| | | foreach($keys as $key) |
| | | { |
| | | $this->put($key,$map->get($key)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public function clear() |
| | | { |
| | | unset($this->m_table); |
| | | //$this->m_table = null; |
| | | $this->m_table = array (); |
| | | } |
| | | |
| | | public function contains_value($value) |
| | | { |
| | | while ($curValue = current($this->m_table)) |
| | | { |
| | | if ($curValue == $value) |
| | | { |
| | | return true; |
| | | } |
| | | next($this->m_table); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public function containsKey($key) |
| | | { |
| | | if (array_key_exists($key, $this->m_table)) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public function size() |
| | | { |
| | | return count($this->m_table); |
| | | } |
| | | |
| | | public function is_empty() |
| | | { |
| | | return (count($this->m_table) == 0); |
| | | } |
| | | |
| | | public function toString() |
| | | { |
| | | print_r($this->m_table); |
| | | } |
| | | } |
| | | |
| | | ?> |
New file |
| | |
| | | <?php |
| | | namespace App\Utils; |
| | | |
| | | use GuzzleHttp\Client; |
| | | use GuzzleHttp\HandlerStack; |
| | | use Hyperf\Guzzle\CoroutineHandler; |
| | | use GuzzleHttp\Exception\ClientException; |
| | | |
| | | use Hyperf\Di\Annotation\Inject; |
| | | use Hyperf\Guzzle\ClientFactory; |
| | | |
| | | class Http { |
| | | |
| | | /** |
| | | * @Inject |
| | | * @var ClientFactory |
| | | */ |
| | | private $clientFactory; |
| | | |
| | | function get_host($url,&$path){ |
| | | $pos=strpos($url,"/",8); |
| | | if (!$pos) { |
| | | $path="/"; |
| | | return $url; |
| | | } |
| | | |
| | | $path=substr($url,$pos); |
| | | return substr($url,0,$pos); |
| | | } |
| | | |
| | | public function get_content_length($url,$time_out=60) |
| | | { |
| | | if ($url=="") { |
| | | return 0; |
| | | } |
| | | |
| | | try { |
| | | |
| | | $options = [ |
| | | 'base_uri' => "", |
| | | 'handler' => HandlerStack::create(new CoroutineHandler()), |
| | | 'timeout' => $time_out, |
| | | 'swoole' => [ |
| | | 'timeout' => $time_out, |
| | | 'socket_buffer_size' => 1024 * 1024 * 2, |
| | | ], |
| | | ]; |
| | | |
| | | $path=""; |
| | | $host=$this->get_host($url,$path); |
| | | if ($host=="") { |
| | | return 0; |
| | | } |
| | | $options["base_uri"]=$host; |
| | | $client = $this->clientFactory->create($options); |
| | | $response=$client->get($path); |
| | | if ($response->getStatusCode()!=200) { |
| | | return 0; |
| | | } |
| | | |
| | | $str_size = $response->getHeader('Content-Length'); |
| | | $size = intval($str_size[0]); |
| | | return $size; |
| | | } catch (ClientException $e) { |
| | | //获取协程中出现的异常。 |
| | | $response_e=$e->getResponse(); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | public function get_web_result($url,$time_out=10) |
| | | { |
| | | if ($url=="") { |
| | | return ""; |
| | | } |
| | | |
| | | $path=""; |
| | | $host=$this->get_host($url,$path); |
| | | if ($host=="") { |
| | | return ""; |
| | | } |
| | | $options = [ |
| | | 'base_uri' => $host, |
| | | 'handler' => HandlerStack::create(new CoroutineHandler()), |
| | | 'timeout' => $time_out, |
| | | 'swoole' => [ |
| | | 'timeout' => $time_out, |
| | | 'socket_buffer_size' => 1024 * 1024 * 2, |
| | | ], |
| | | ]; |
| | | |
| | | try { |
| | | //var_dump($this->clientFactory); |
| | | $client = $this->clientFactory->create($options); |
| | | $response=$client->get($path); |
| | | if ($response->getStatusCode()==200) { |
| | | $strContent=$response->getBody()->getContents(); |
| | | //echo "$strContent\r\n"; |
| | | return $strContent; |
| | | } |
| | | |
| | | } catch (ClientException $e) { |
| | | //获取协程中出现的异常。 |
| | | var_dump($e->getResponse()); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | public function post_web_result($url,$post_data,$time_out=10) |
| | | { |
| | | |
| | | if ($url=="") { |
| | | return ""; |
| | | } |
| | | |
| | | |
| | | $path=""; |
| | | $host=$this->get_host($url,$path); |
| | | if ($host=="") { |
| | | return ""; |
| | | } |
| | | |
| | | $options = [ |
| | | 'base_uri' => $host, |
| | | 'handler' => HandlerStack::create(new CoroutineHandler()), |
| | | 'timeout' => $time_out, |
| | | 'swoole' => [ |
| | | 'timeout' => $time_out, |
| | | 'socket_buffer_size' => 1024 * 1024 * 2, |
| | | ], |
| | | ]; |
| | | |
| | | try { |
| | | $client = $this->clientFactory->create($options); |
| | | $response = $client->request('POST', $url, ['form_params' => $post_data]); |
| | | //debug |
| | | //$response = $client->request('POST', $url, ['form_params' => $post_data,'debug' => true]); |
| | | if ($response->getStatusCode()==200) { |
| | | $strContent=$response->getBody()->getContents(); |
| | | //echo "$strContent\r\n"; |
| | | return $strContent; |
| | | } |
| | | |
| | | } catch (ClientException $e) { |
| | | //获取协程中出现的异常。 |
| | | //var_dump($e->getResponse()); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | public function post_json_result($url,$post_data,$time_out=10) |
| | | { |
| | | |
| | | if ($url=="") { |
| | | return ""; |
| | | } |
| | | |
| | | $path=""; |
| | | $host=$this->get_host($url,$path); |
| | | if ($host=="") { |
| | | return ""; |
| | | } |
| | | |
| | | $options = [ |
| | | 'base_uri' => $host, |
| | | 'handler' => HandlerStack::create(new CoroutineHandler()), |
| | | 'timeout' => $time_out, |
| | | 'swoole' => [ |
| | | 'timeout' => $time_out, |
| | | 'socket_buffer_size' => 1024 * 1024 * 2, |
| | | ], |
| | | ]; |
| | | |
| | | try { |
| | | $client = $this->clientFactory->create($options); |
| | | if (is_array($post_data)) { |
| | | $response = $client->request('POST', $url, ['body' => json_encode($post_data),"headers"=>['Accept'=> 'application/json']]); |
| | | }else{ |
| | | $response = $client->request('POST', $url, ['body' => $post_data,"headers"=>['Accept'=> 'application/json']]); |
| | | } |
| | | //debug |
| | | //$response = $client->request('POST', $url, ['form_params' => $post_data,'debug' => true]); |
| | | if ($response->getStatusCode()==200) { |
| | | $strContent=$response->getBody()->getContents(); |
| | | //echo "$strContent\r\n"; |
| | | return $strContent; |
| | | } |
| | | |
| | | } catch (ClientException $e) { |
| | | //获取协程中出现的异常。 |
| | | var_dump($e->getResponse()); |
| | | } |
| | | return ""; |
| | | } |
| | | } |
New file |
| | |
| | | <?php |
| | | |
| | | /** |
| | | *文件名:UserInfo.php |
| | | *编写人:杨林康 |
| | | *时间 :2014-04-23 |
| | | *功能 :生成Guid |
| | | *备注 :使用时GUID::create()生成guid |
| | | */ |
| | | namespace App\Utils; |
| | | |
| | | class guid |
| | | { |
| | | public static function create() |
| | | { |
| | | $microTime = microtime(); |
| | | list($a_dec, $a_sec) = explode(" ", $microTime); |
| | | $dec_hex = dechex($a_dec* 1000000); |
| | | $sec_hex = dechex($a_sec); |
| | | guid::ensureLength($dec_hex, 5); |
| | | guid::ensureLength($sec_hex, 6); |
| | | $guid = ""; |
| | | $guid .= $dec_hex; |
| | | $guid .= guid::createGuidSection(3); |
| | | $guid .= '-'; |
| | | $guid .= guid::createGuidSection(4); |
| | | $guid .= '-'; |
| | | $guid .= guid::createGuidSection(4); |
| | | $guid .= '-'; |
| | | $guid .= guid::createGuidSection(4); |
| | | $guid .= '-'; |
| | | $guid .= $sec_hex; |
| | | $guid .= guid::createGuidSection(6); |
| | | $ret = str_replace("-","",$guid); |
| | | return $ret; |
| | | } |
| | | |
| | | public static function getGuid(){ |
| | | $microTime = microtime(); |
| | | list($a_dec, $a_sec) = explode(" ", $microTime); |
| | | $dec_hex = dechex($a_dec* 1000000); |
| | | $sec_hex = dechex($a_sec); |
| | | guid::ensureLength($dec_hex, 5); |
| | | guid::ensureLength($sec_hex, 6); |
| | | $guid = ""; |
| | | $guid .= $dec_hex; |
| | | $guid .= guid::createGuidSection(3); |
| | | $guid .= guid::createGuidSection(4); |
| | | $guid .= guid::createGuidSection(4); |
| | | $guid .= guid::createGuidSection(4); |
| | | $guid .= $sec_hex; |
| | | $guid .= guid::createGuidSection(6); |
| | | return $guid; |
| | | } |
| | | |
| | | public static function ensureLength(&$string, $length) |
| | | { |
| | | $strlen = strlen($string); |
| | | if($strlen < $length) |
| | | { |
| | | $string = str_pad($string,$length,"0"); |
| | | } |
| | | else if($strlen > $length) |
| | | { |
| | | $string = substr($string, 0, $length); |
| | | } |
| | | } |
| | | |
| | | public static function createGuidSection($characters) |
| | | { |
| | | $return = ""; |
| | | for($i=0; $i<$characters; $i++) |
| | | { |
| | | $return .= dechex(mt_rand(0,15)); |
| | | } |
| | | return $return; |
| | | } |
| | | } |
New file |
| | |
| | | #!/usr/bin/env php |
| | | <?php |
| | | |
| | | ini_set('display_errors', 'on'); |
| | | ini_set('display_startup_errors', 'on'); |
| | | ini_set('memory_limit', '1G'); |
| | | |
| | | error_reporting(E_ALL); |
| | | |
| | | ! defined('BASE_PATH') && define('BASE_PATH', dirname(__DIR__, 1)); |
| | | ! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL); |
| | | |
| | | require BASE_PATH . '/vendor/autoload.php'; |
| | | |
| | | // Self-called anonymous function that creates its own scope and keep the global namespace clean. |
| | | (function () { |
| | | Hyperf\Di\ClassLoader::init(); |
| | | /** @var Psr\Container\ContainerInterface $container */ |
| | | $container = require BASE_PATH . '/config/container.php'; |
| | | |
| | | $application = $container->get(Hyperf\Contract\ApplicationInterface::class); |
| | | $application->run(); |
| | | })(); |
New file |
| | |
| | | { |
| | | "name": "hyperf/hyperf-skeleton", |
| | | "type": "project", |
| | | "keywords": [ |
| | | "php", |
| | | "swoole", |
| | | "framework", |
| | | "hyperf", |
| | | "microservice", |
| | | "middleware" |
| | | ], |
| | | "description": "A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.", |
| | | "license": "Apache-2.0", |
| | | "require": { |
| | | "php": ">=7.3", |
| | | "hyperf/cache": "~2.2.0", |
| | | "hyperf/command": "~2.2.0", |
| | | "hyperf/config": "~2.2.0", |
| | | "hyperf/di": "^2.2", |
| | | "hyperf/framework": "~2.2.0", |
| | | "hyperf/guzzle": "~2.2.0", |
| | | "hyperf/http-server": "~2.2.0", |
| | | "hyperf/logger": "~2.2.0", |
| | | "hyperf/memory": "~2.2.0", |
| | | "hyperf/process": "~2.2.0", |
| | | "hyperf/redis": "~2.2.0", |
| | | "hyperf/websocket-server": "^2.2" |
| | | }, |
| | | "require-dev": { |
| | | "friendsofphp/php-cs-fixer": "^3.0", |
| | | "hyperf/devtool": "~2.2.0", |
| | | "hyperf/ide-helper": "~2.2.0", |
| | | "hyperf/testing": "~2.2.0", |
| | | "mockery/mockery": "^1.0", |
| | | "phpstan/phpstan": "^0.12", |
| | | "swoole/ide-helper": "^4.5" |
| | | }, |
| | | "suggest": { |
| | | "ext-openssl": "Required to use HTTPS.", |
| | | "ext-json": "Required to use JSON.", |
| | | "ext-pdo": "Required to use MySQL Client.", |
| | | "ext-pdo_mysql": "Required to use MySQL Client.", |
| | | "ext-redis": "Required to use Redis Client." |
| | | }, |
| | | "autoload": { |
| | | "psr-4": { |
| | | "App\\": "app/" |
| | | }, |
| | | "files": [] |
| | | }, |
| | | "autoload-dev": { |
| | | "psr-4": { |
| | | "HyperfTest\\": "./test/" |
| | | } |
| | | }, |
| | | "minimum-stability": "dev", |
| | | "prefer-stable": true, |
| | | "config": { |
| | | "optimize-autoloader": true, |
| | | "sort-packages": true |
| | | }, |
| | | "extra": [], |
| | | "scripts": { |
| | | "post-root-package-install": [ |
| | | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" |
| | | ], |
| | | "post-autoload-dump": [ |
| | | "rm -rf runtime/container" |
| | | ], |
| | | "test": "co-phpunit --prepend test/bootstrap.php -c phpunit.xml --colors=always", |
| | | "cs-fix": "php-cs-fixer fix $1", |
| | | "analyse": "phpstan analyse --memory-limit 300M -l 0 -c phpstan.neon ./app ./config", |
| | | "start": [ |
| | | "Composer\\Config::disableProcessTimeout", |
| | | "php ./bin/hyperf.php start" |
| | | ] |
| | | } |
| | | } |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | 'scan' => [ |
| | | 'paths' => [ |
| | | BASE_PATH . '/app', |
| | | ], |
| | | 'ignore_annotations' => [ |
| | | 'mixin', |
| | | ], |
| | | ], |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | 'default' => [ |
| | | 'driver' => Hyperf\Cache\Driver\RedisDriver::class, |
| | | 'packer' => Hyperf\Utils\Packer\PhpSerializerPacker::class, |
| | | 'prefix' => 'c:', |
| | | ], |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | 'default' => [ |
| | | 'driver' => env('DB_DRIVER', 'mysql'), |
| | | 'host' => env('DB_HOST', 'localhost'), |
| | | 'database' => env('DB_DATABASE', 'hyperf'), |
| | | 'port' => env('DB_PORT', 3306), |
| | | 'username' => env('DB_USERNAME', 'root'), |
| | | 'password' => env('DB_PASSWORD', ''), |
| | | 'charset' => env('DB_CHARSET', 'utf8'), |
| | | 'collation' => env('DB_COLLATION', 'utf8_unicode_ci'), |
| | | 'prefix' => env('DB_PREFIX', ''), |
| | | 'pool' => [ |
| | | 'min_connections' => 1, |
| | | 'max_connections' => 10, |
| | | 'connect_timeout' => 10.0, |
| | | 'wait_timeout' => 3.0, |
| | | 'heartbeat' => -1, |
| | | 'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60), |
| | | ], |
| | | 'commands' => [ |
| | | 'gen:model' => [ |
| | | 'path' => 'app/Model', |
| | | 'force_casts' => true, |
| | | 'inheritance' => 'Model', |
| | | ], |
| | | ], |
| | | ], |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | 'generator' => [ |
| | | 'amqp' => [ |
| | | 'consumer' => [ |
| | | 'namespace' => 'App\\Amqp\\Consumer', |
| | | ], |
| | | 'producer' => [ |
| | | 'namespace' => 'App\\Amqp\\Producer', |
| | | ], |
| | | ], |
| | | 'aspect' => [ |
| | | 'namespace' => 'App\\Aspect', |
| | | ], |
| | | 'command' => [ |
| | | 'namespace' => 'App\\Command', |
| | | ], |
| | | 'controller' => [ |
| | | 'namespace' => 'App\\Controller', |
| | | ], |
| | | 'job' => [ |
| | | 'namespace' => 'App\\Job', |
| | | ], |
| | | 'listener' => [ |
| | | 'namespace' => 'App\\Listener', |
| | | ], |
| | | 'middleware' => [ |
| | | 'namespace' => 'App\\Middleware', |
| | | ], |
| | | 'Process' => [ |
| | | 'namespace' => 'App\\Processes', |
| | | ], |
| | | ], |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | 'handler' => [ |
| | | 'http' => [ |
| | | Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class, |
| | | App\Exception\Handler\AppExceptionHandler::class, |
| | | Hyperf\WebSocketServer\Exception\Handler\WebSocketExceptionHandler::class, |
| | | ], |
| | | ], |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | 'default' => [ |
| | | 'handler' => [ |
| | | 'class' => Monolog\Handler\RotatingFileHandler::class, |
| | | 'constructor' => [ |
| | | 'filename' => BASE_PATH . '/logs/ws.log', |
| | | 'level' => Monolog\Logger::DEBUG, |
| | | ], |
| | | ], |
| | | 'formatter' => [ |
| | | 'class' => Monolog\Formatter\LineFormatter::class, |
| | | 'constructor' => [ |
| | | 'format' => null, |
| | | 'dateFormat' => 'Y-m-d H:i:s', |
| | | 'allowInlineLineBreaks' => true, |
| | | ], |
| | | ], |
| | | ], |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | 'http' => [ |
| | | ], |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | return [ |
| | | 'default' => [ |
| | | 'host' => env('REDIS_HOST', 'localhost'), |
| | | 'auth' => env('REDIS_AUTH', null), |
| | | 'port' => (int) env('REDIS_PORT', 6379), |
| | | 'db' => (int) env('REDIS_DB', 0), |
| | | 'pool' => [ |
| | | 'min_connections' => 1, |
| | | 'max_connections' => 10, |
| | | 'connect_timeout' => 10.0, |
| | | 'wait_timeout' => 3.0, |
| | | 'heartbeat' => -1, |
| | | 'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60), |
| | | ], |
| | | ], |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | use Hyperf\Server\Event; |
| | | use Hyperf\Server\Server; |
| | | use Hyperf\Server\SwooleEvent; |
| | | use Swoole\Constant; |
| | | |
| | | return [ |
| | | 'mode' => SWOOLE_PROCESS, |
| | | 'servers' => [ |
| | | [ |
| | | 'name' => 'ws', |
| | | 'type' => Server::SERVER_WEBSOCKET, |
| | | 'host' => '0.0.0.0', |
| | | 'port' => 9501, |
| | | 'sock_type' => SWOOLE_SOCK_TCP, |
| | | 'allow_ip' => '120.25.156.26.58005', |
| | | 'callbacks' => [ |
| | | SwooleEvent::ON_HAND_SHAKE => [Hyperf\WebSocketServer\Server::class, 'onHandShake'], |
| | | SwooleEvent::ON_MESSAGE => [Hyperf\WebSocketServer\Server::class, 'onMessage'], |
| | | SwooleEvent::ON_CLOSE => [Hyperf\WebSocketServer\Server::class, 'onClose'], |
| | | SwooleEvent::ON_START => [App\Controller\WebsocketController::class, 'onStart'], |
| | | ], |
| | | ], |
| | | ], |
| | | 'settings' => [ |
| | | Constant::OPTION_ENABLE_COROUTINE => true, |
| | | //Constant::OPTION_DAEMONIZE=>1, |
| | | Constant::OPTION_DISPATCH_MODE=>2, |
| | | Constant::OPTION_WORKER_NUM => swoole_cpu_num(), |
| | | Constant::OPTION_PID_FILE => BASE_PATH . '/runtime/hyperf.pid', |
| | | Constant::OPTION_OPEN_TCP_NODELAY => true, |
| | | Constant::OPTION_MAX_COROUTINE => 100000, |
| | | Constant::OPTION_OPEN_HTTP2_PROTOCOL => true, |
| | | Constant::OPTION_MAX_REQUEST => 100000, |
| | | Constant::OPTION_SOCKET_BUFFER_SIZE => 2 * 1024 * 1024, |
| | | Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024, |
| | | ], |
| | | 'callbacks' => [ |
| | | Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], |
| | | Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'], |
| | | Event::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], |
| | | ], |
| | | ]; |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | use Hyperf\Contract\StdoutLoggerInterface; |
| | | use Psr\Log\LogLevel; |
| | | |
| | | return [ |
| | | 'app_name' => env('APP_NAME', 'skeleton'), |
| | | 'app_env' => env('APP_ENV', 'dev'), |
| | | 'node_name' => env('NODE_NAME', 'node_1'), |
| | | 'file_path'=>ENV("FILE_PATH","../file/"), |
| | | 'scan_cacheable' => env('SCAN_CACHEABLE', false), |
| | | StdoutLoggerInterface::class => [ |
| | | 'log_level' => [ |
| | | LogLevel::ALERT, |
| | | LogLevel::CRITICAL, |
| | | //LogLevel::DEBUG, |
| | | LogLevel::EMERGENCY, |
| | | LogLevel::ERROR, |
| | | LogLevel::INFO, |
| | | LogLevel::NOTICE, |
| | | LogLevel::WARNING, |
| | | ], |
| | | ], |
| | | ]; |
New file |
| | |
| | | <?php |
| | | /** |
| | | * Initialize a dependency injection container that implemented PSR-11 and return the container. |
| | | */ |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | use Hyperf\Di\Container; |
| | | use Hyperf\Di\Definition\DefinitionSourceFactory; |
| | | use Hyperf\Utils\ApplicationContext; |
| | | |
| | | $container = new Container((new DefinitionSourceFactory(true))()); |
| | | |
| | | if (! $container instanceof \Psr\Container\ContainerInterface) { |
| | | throw new RuntimeException('The dependency injection container is invalid.'); |
| | | } |
| | | return ApplicationContext::setContainer($container); |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types=1); |
| | | /** |
| | | * This file is part of Hyperf. |
| | | * |
| | | * @link https://www.hyperf.io |
| | | * @document https://hyperf.wiki |
| | | * @contact group@hyperf.io |
| | | * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| | | */ |
| | | use Hyperf\HttpServer\Router\Router; |
| | | |
| | | Router::addServer('ws', function () { |
| | | Router::get('/', App\Controller\WebsocketController::class); |
| | | }); |
New file |
| | |
| | | <!DOCTYPE html> |
| | | |
| | | <head> |
| | | <title>socket demo</title> |
| | | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| | | <script type="text/javascript" src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script> |
| | | </head> |
| | | |
| | | <body> |
| | | <input type="text" id="msg" /> |
| | | <button id="send">发送</button> |
| | | </body> |
| | | |
| | | </html> |
| | | <script> |
| | | $(function() { |
| | | // 创建socket对象 |
| | | var socket = new WebSocket('ws://127.0.0.1:9501'); |
| | | |
| | | // 打开Socket |
| | | socket.onopen = function(event) { |
| | | |
| | | $('#send').on('click', function() { |
| | | var msg = $('#msg').val(); |
| | | var url = 'application/index/data'; |
| | | var fullData = { |
| | | url: url, |
| | | data: { |
| | | session_id: '1a2e0ca9c7404b765a37a5ab07546fa8', |
| | | group_id: '1a2e0ca9c7404b765a37a5ab07546fa8', |
| | | msg: msg |
| | | } |
| | | }; |
| | | socket.send(JSON.stringify(fullData)); |
| | | console.log(msg); |
| | | }); |
| | | var url = 'application/index/reg'; |
| | | var fullData = { |
| | | url: url, |
| | | data: { |
| | | session_id: '1a2e0ca9c7404b765a37a5ab07546fa8', |
| | | group_id: '1a2e0ca9c7404b765a37a5ab07546fa8' |
| | | } |
| | | }; |
| | | // 发送一个初始化消息 |
| | | socket.send(JSON.stringify(fullData)); |
| | | if (socket.readyState == 1) { |
| | | // setInterval(function() { |
| | | // var fullData = { |
| | | // url: 'plumeWSService/cluster/ping', |
| | | // data: 'ping' |
| | | // }; |
| | | // socket.send(JSON.stringify(fullData)); |
| | | // }, 1000) |
| | | } |
| | | // 监听消息 |
| | | socket.onmessage = function(event) { |
| | | if (event.data == 'pingpong') { //处理心跳接收事件 |
| | | |
| | | } else { |
| | | var fullData = JSON.parse(event.data); |
| | | console.log("客户端监听到的消息:", fullData); |
| | | } |
| | | }; |
| | | |
| | | // 监听Socket的关闭 |
| | | socket.onclose = function(event) { |
| | | console.log("Socket关闭了", event); |
| | | }; |
| | | |
| | | // 关闭Socket.... |
| | | //socket.close() |
| | | }; |
| | | }); |
| | | </script> |
New file |
| | |
| | | a:2:{i:0;s:36:"Hyperf\Config\Annotation\ValueAspect";i:1;s:33:"Hyperf\Di\Annotation\InjectAspect";} |
New file |
| | |
| | | a:403:{i:0;s:36:"Hyperf\Cache\Listener\DeleteListener";i:1;s:33:"Hyperf\Cache\Listener\DeleteEvent";i:2;s:41:"Hyperf\Cache\Listener\DeleteListenerEvent";i:3;s:41:"Hyperf\Cache\Driver\CoroutineMemoryDriver";i:4;s:41:"Hyperf\Cache\Driver\KeyCollectorInterface";i:5;s:31:"Hyperf\Cache\Driver\RedisDriver";i:6;s:36:"Hyperf\Cache\Driver\FileSystemDriver";i:7;s:26:"Hyperf\Cache\Driver\Driver";i:8;s:35:"Hyperf\Cache\Driver\DriverInterface";i:9;s:18:"Hyperf\Cache\Cache";i:10;s:25:"Hyperf\Cache\CacheManager";i:11;s:38:"Hyperf\Cache\Collector\CoroutineMemory";i:12;s:41:"Hyperf\Cache\Collector\CoroutineMemoryKey";i:13;s:34:"Hyperf\Cache\Collector\FileStorage";i:14;s:33:"Hyperf\Cache\Annotation\FailCache";i:15;s:33:"Hyperf\Cache\Annotation\Cacheable";i:16;s:34:"Hyperf\Cache\Annotation\CacheEvict";i:17;s:32:"Hyperf\Cache\Annotation\CachePut";i:18;s:35:"Hyperf\Cache\CacheListenerCollector";i:19;s:30:"Hyperf\Cache\AnnotationManager";i:20;s:36:"Hyperf\Cache\Aspect\CacheEvictAspect";i:21;s:35:"Hyperf\Cache\Aspect\CacheableAspect";i:22;s:34:"Hyperf\Cache\Aspect\CachePutAspect";i:23;s:35:"Hyperf\Cache\Aspect\FailCacheAspect";i:24;s:27:"Hyperf\Cache\ConfigProvider";i:25;s:32:"Hyperf\Cache\Helper\StringHelper";i:26;s:47:"Hyperf\Cache\Exception\InvalidArgumentException";i:27;s:37:"Hyperf\Cache\Exception\CacheException";i:28;s:54:"Hyperf\Config\Listener\RegisterPropertyHandlerListener";i:29;s:28:"Hyperf\Config\ProviderConfig";i:30;s:36:"Hyperf\Config\Annotation\ValueAspect";i:31;s:30:"Hyperf\Config\Annotation\Value";i:32;s:20:"Hyperf\Config\Config";i:33;s:27:"Hyperf\Config\ConfigFactory";i:34;s:28:"Hyperf\Config\ConfigProvider";i:35;s:36:"Hyperf\Di\ClosureDefinitionCollector";i:36;s:36:"Hyperf\Di\MetadataCollectorInterface";i:37;s:19:"Hyperf\Di\Container";i:38;s:27:"Hyperf\Di\ReflectionManager";i:39;s:40:"Hyperf\Di\LazyLoader\PublicMethodVisitor";i:40;s:31:"Hyperf\Di\LazyLoader\LazyLoader";i:41;s:42:"Hyperf\Di\LazyLoader\ClassLazyProxyBuilder";i:42;s:45:"Hyperf\Di\LazyLoader\FallbackLazyProxyBuilder";i:43;s:45:"Hyperf\Di\LazyLoader\AbstractLazyProxyBuilder";i:44;s:46:"Hyperf\Di\LazyLoader\InterfaceLazyProxyBuilder";i:45;s:21:"Hyperf\Di\ClassLoader";i:46;s:44:"Hyperf\Di\MethodDefinitionCollectorInterface";i:47;s:45:"Hyperf\Di\ClosureDefinitionCollectorInterface";i:48;s:45:"Hyperf\Di\AbstractCallableDefinitionCollector";i:49;s:27:"Hyperf\Di\Annotation\Inject";i:50;s:39:"Hyperf\Di\Annotation\AbstractAnnotation";i:51;s:36:"Hyperf\Di\Annotation\AspectCollector";i:52;s:39:"Hyperf\Di\Annotation\MultipleAnnotation";i:53;s:31:"Hyperf\Di\Annotation\ScanConfig";i:54;s:33:"Hyperf\Di\Annotation\AspectLoader";i:55;s:26:"Hyperf\Di\Annotation\Debug";i:56;s:48:"Hyperf\Di\Annotation\MultipleAnnotationInterface";i:57;s:40:"Hyperf\Di\Annotation\AnnotationCollector";i:58;s:33:"Hyperf\Di\Annotation\InjectAspect";i:59;s:40:"Hyperf\Di\Annotation\AnnotationInterface";i:60;s:28:"Hyperf\Di\Annotation\Scanner";i:61;s:27:"Hyperf\Di\Annotation\Aspect";i:62;s:47:"Hyperf\Di\Annotation\AbstractMultipleAnnotation";i:63;s:37:"Hyperf\Di\Annotation\AnnotationReader";i:64;s:38:"Hyperf\Di\Annotation\RelationCollector";i:65;s:26:"Hyperf\Di\Aop\ProxyManager";i:66;s:29:"Hyperf\Di\Aop\VisitorMetadata";i:67;s:36:"Hyperf\Di\Aop\PropertyHandlerVisitor";i:68;s:32:"Hyperf\Di\Aop\AstVisitorRegistry";i:69;s:43:"Hyperf\Di\Aop\RegisterInjectPropertyHandler";i:70;s:28:"Hyperf\Di\Aop\AbstractAspect";i:71;s:27:"Hyperf\Di\Aop\AspectManager";i:72;s:31:"Hyperf\Di\Aop\RewriteCollection";i:73;s:30:"Hyperf\Di\Aop\ProxyCallVisitor";i:74;s:33:"Hyperf\Di\Aop\ProceedingJoinPoint";i:75;s:22:"Hyperf\Di\Aop\Pipeline";i:76;s:20:"Hyperf\Di\Aop\Aspect";i:77;s:17:"Hyperf\Di\Aop\Ast";i:78;s:32:"Hyperf\Di\Aop\AnnotationMetadata";i:79;s:29:"Hyperf\Di\Aop\AroundInterface";i:80;s:35:"Hyperf\Di\MethodDefinitionCollector";i:81;s:36:"Hyperf\Di\Definition\MethodInjection";i:82;s:53:"Hyperf\Di\Definition\SelfResolvingDefinitionInterface";i:83;s:38:"Hyperf\Di\Definition\FactoryDefinition";i:84;s:31:"Hyperf\Di\Definition\ScanConfig";i:85;s:30:"Hyperf\Di\Definition\Reference";i:86;s:46:"Hyperf\Di\Definition\DefinitionSourceInterface";i:87;s:37:"Hyperf\Di\Definition\DefinitionSource";i:88;s:43:"Hyperf\Di\Definition\PropertyHandlerManager";i:89;s:40:"Hyperf\Di\Definition\DefinitionInterface";i:90;s:37:"Hyperf\Di\Definition\ObjectDefinition";i:91;s:39:"Hyperf\Di\Definition\PropertyDefinition";i:92;s:44:"Hyperf\Di\Definition\DefinitionSourceFactory";i:93;s:24:"Hyperf\Di\ReflectionType";i:94;s:32:"Hyperf\Di\MetadataCacheCollector";i:95;s:24:"Hyperf\Di\ConfigProvider";i:96;s:39:"Hyperf\Di\Exception\AnnotationException";i:97;s:46:"Hyperf\Di\Exception\InvalidDefinitionException";i:98;s:37:"Hyperf\Di\Exception\NotFoundException";i:99;s:47:"Hyperf\Di\Exception\CircularDependencyException";i:100;s:44:"Hyperf\Di\Exception\InvalidArgumentException";i:101;s:46:"Hyperf\Di\Exception\DirectoryNotExistException";i:102;s:47:"Hyperf\Di\Exception\ConflictAnnotationException";i:103;s:39:"Hyperf\Di\Exception\DependencyException";i:104;s:29:"Hyperf\Di\Exception\Exception";i:105;s:27:"Hyperf\Di\MetadataCollector";i:106;s:33:"Hyperf\Di\Resolver\ObjectResolver";i:107;s:37:"Hyperf\Di\Resolver\ResolverDispatcher";i:108;s:29:"Hyperf\Di\Resolver\DepthGuard";i:109;s:36:"Hyperf\Di\Resolver\ResolverInterface";i:110;s:34:"Hyperf\Di\Resolver\FactoryResolver";i:111;s:36:"Hyperf\Di\Resolver\ParameterResolver";i:112;s:36:"Hyperf\Dispatcher\HttpRequestHandler";i:113;s:53:"Hyperf\Dispatcher\Exceptions\InvalidArgumentException";i:114;s:40:"Hyperf\Dispatcher\AbstractRequestHandler";i:115;s:32:"Hyperf\Dispatcher\HttpDispatcher";i:116;s:36:"Hyperf\Dispatcher\AbstractDispatcher";i:117;s:32:"Hyperf\Dispatcher\ConfigProvider";i:118;s:29:"Hyperf\Event\ListenerProvider";i:119;s:39:"Hyperf\Event\Contract\ListenerInterface";i:120;s:25:"Hyperf\Event\ListenerData";i:121;s:32:"Hyperf\Event\Annotation\Listener";i:122;s:35:"Hyperf\Event\EventDispatcherFactory";i:123;s:28:"Hyperf\Event\EventDispatcher";i:124;s:36:"Hyperf\Event\ListenerProviderFactory";i:125;s:27:"Hyperf\Event\ConfigProvider";i:126;s:54:"Hyperf\ExceptionHandler\Handler\WhoopsExceptionHandler";i:127;s:54:"Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler";i:128;s:57:"Hyperf\ExceptionHandler\Listener\ExceptionHandlerListener";i:129;s:50:"Hyperf\ExceptionHandler\ExceptionHandlerDispatcher";i:130;s:51:"Hyperf\ExceptionHandler\Annotation\ExceptionHandler";i:131;s:52:"Hyperf\ExceptionHandler\Formatter\FormatterInterface";i:132;s:50:"Hyperf\ExceptionHandler\Formatter\DefaultFormatter";i:133;s:35:"Hyperf\ExceptionHandler\Propagation";i:134;s:40:"Hyperf\ExceptionHandler\ExceptionHandler";i:135;s:38:"Hyperf\ExceptionHandler\ConfigProvider";i:136;s:36:"Hyperf\Framework\Logger\StdoutLogger";i:137;s:45:"Hyperf\Framework\Bootstrap\WorkerExitCallback";i:138;s:43:"Hyperf\Framework\Bootstrap\ShutdownCallback";i:139;s:41:"Hyperf\Framework\Bootstrap\PacketCallback";i:140;s:46:"Hyperf\Framework\Bootstrap\WorkerStartCallback";i:141;s:40:"Hyperf\Framework\Bootstrap\CloseCallback";i:142;s:39:"Hyperf\Framework\Bootstrap\TaskCallback";i:143;s:47:"Hyperf\Framework\Bootstrap\ManagerStartCallback";i:144;s:45:"Hyperf\Framework\Bootstrap\WorkerStopCallback";i:145;s:46:"Hyperf\Framework\Bootstrap\ServerStartCallback";i:146;s:40:"Hyperf\Framework\Bootstrap\StartCallback";i:147;s:42:"Hyperf\Framework\Bootstrap\ConnectCallback";i:148;s:46:"Hyperf\Framework\Bootstrap\WorkerErrorCallback";i:149;s:42:"Hyperf\Framework\Bootstrap\ReceiveCallback";i:150;s:46:"Hyperf\Framework\Bootstrap\ManagerStopCallback";i:151;s:41:"Hyperf\Framework\Bootstrap\FinishCallback";i:152;s:46:"Hyperf\Framework\Bootstrap\PipeMessageCallback";i:153;s:35:"Hyperf\Framework\ApplicationFactory";i:154;s:31:"Hyperf\Framework\ConfigProvider";i:155;s:50:"Hyperf\Framework\Exception\NotImplementedException";i:156;s:35:"Hyperf\Framework\Event\OnWorkerExit";i:157;s:39:"Hyperf\Framework\Event\AfterWorkerStart";i:158;s:40:"Hyperf\Framework\Event\BeforeWorkerStart";i:159;s:39:"Hyperf\Framework\Event\OtherWorkerStart";i:160;s:31:"Hyperf\Framework\Event\OnFinish";i:161;s:31:"Hyperf\Framework\Event\OnPacket";i:162;s:36:"Hyperf\Framework\Event\OnWorkerError";i:163;s:29:"Hyperf\Framework\Event\OnTask";i:164;s:37:"Hyperf\Framework\Event\OnManagerStart";i:165;s:36:"Hyperf\Framework\Event\OnManagerStop";i:166;s:30:"Hyperf\Framework\Event\OnClose";i:167;s:38:"Hyperf\Framework\Event\BootApplication";i:168;s:32:"Hyperf\Framework\Event\OnReceive";i:169;s:30:"Hyperf\Framework\Event\OnStart";i:170;s:40:"Hyperf\Framework\Event\BeforeServerStart";i:171;s:36:"Hyperf\Framework\Event\OnPipeMessage";i:172;s:35:"Hyperf\Framework\Event\OnWorkerStop";i:173;s:44:"Hyperf\Framework\Event\BeforeMainServerStart";i:174;s:33:"Hyperf\Framework\Event\OnShutdown";i:175;s:32:"Hyperf\Framework\Event\OnConnect";i:176;s:38:"Hyperf\Framework\Event\MainWorkerStart";i:177;s:33:"Hyperf\Guzzle\MiddlewareInterface";i:178;s:27:"Hyperf\Guzzle\ClientFactory";i:179;s:33:"Hyperf\Guzzle\HandlerStackFactory";i:180;s:30:"Hyperf\Guzzle\CoroutineHandler";i:181;s:29:"Hyperf\Guzzle\RetryMiddleware";i:182;s:25:"Hyperf\Guzzle\PoolHandler";i:183;s:28:"Hyperf\Guzzle\ConfigProvider";i:184;s:38:"Hyperf\Guzzle\RingPHP\CoroutineHandler";i:185;s:33:"Hyperf\Guzzle\RingPHP\PoolHandler";i:186;s:50:"Hyperf\HttpServer\Contract\CoreMiddlewareInterface";i:187;s:43:"Hyperf\HttpServer\Contract\RequestInterface";i:188;s:44:"Hyperf\HttpServer\Contract\ResponseInterface";i:189;s:24:"Hyperf\HttpServer\Server";i:190;s:26:"Hyperf\HttpServer\Response";i:191;s:39:"Hyperf\HttpServer\Annotation\GetMapping";i:192;s:39:"Hyperf\HttpServer\Annotation\Controller";i:193;s:43:"Hyperf\HttpServer\Annotation\RequestMapping";i:194;s:43:"Hyperf\HttpServer\Annotation\AutoController";i:195;s:42:"Hyperf\HttpServer\Annotation\DeleteMapping";i:196;s:36:"Hyperf\HttpServer\Annotation\Mapping";i:197;s:40:"Hyperf\HttpServer\Annotation\Middlewares";i:198;s:39:"Hyperf\HttpServer\Annotation\PutMapping";i:199;s:41:"Hyperf\HttpServer\Annotation\PatchMapping";i:200;s:39:"Hyperf\HttpServer\Annotation\Middleware";i:201;s:40:"Hyperf\HttpServer\Annotation\PostMapping";i:202;s:32:"Hyperf\HttpServer\CoreMiddleware";i:203;s:25:"Hyperf\HttpServer\Request";i:204;s:33:"Hyperf\HttpServer\ResponseEmitter";i:205;s:32:"Hyperf\HttpServer\ConfigProvider";i:206;s:56:"Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler";i:207;s:57:"Hyperf\HttpServer\Exception\Http\InvalidResponseException";i:208;s:50:"Hyperf\HttpServer\Exception\Http\EncodingException";i:209;s:46:"Hyperf\HttpServer\Exception\Http\FileException";i:210;s:35:"Hyperf\HttpServer\MiddlewareManager";i:211;s:32:"Hyperf\HttpServer\Router\Handler";i:212;s:35:"Hyperf\HttpServer\Router\Dispatched";i:213;s:39:"Hyperf\HttpServer\Router\RouteCollector";i:214;s:31:"Hyperf\HttpServer\Router\Router";i:215;s:42:"Hyperf\HttpServer\Router\DispatcherFactory";i:216;s:20:"Hyperf\Logger\Logger";i:217;s:27:"Hyperf\Logger\LoggerFactory";i:218;s:28:"Hyperf\Logger\ConfigProvider";i:219;s:46:"Hyperf\Logger\Exception\InvalidConfigException";i:220;s:25:"Hyperf\Memory\LockManager";i:221;s:27:"Hyperf\Memory\AtomicManager";i:222;s:26:"Hyperf\Memory\TableManager";i:223;s:28:"Hyperf\Memory\ConfigProvider";i:224;s:22:"Hyperf\Pool\Connection";i:225;s:33:"Hyperf\Pool\SimplePool\Connection";i:226;s:27:"Hyperf\Pool\SimplePool\Pool";i:227;s:29:"Hyperf\Pool\SimplePool\Config";i:228;s:34:"Hyperf\Pool\SimplePool\PoolFactory";i:229;s:31:"Hyperf\Pool\KeepaliveConnection";i:230;s:29:"Hyperf\Pool\ConstantFrequency";i:231;s:16:"Hyperf\Pool\Pool";i:232;s:19:"Hyperf\Pool\Context";i:233;s:21:"Hyperf\Pool\Frequency";i:234;s:19:"Hyperf\Pool\Channel";i:235;s:22:"Hyperf\Pool\PoolOption";i:236;s:26:"Hyperf\Pool\ConfigProvider";i:237;s:46:"Hyperf\Pool\Exception\InvalidArgumentException";i:238;s:40:"Hyperf\Pool\Exception\SocketPopException";i:239;s:41:"Hyperf\Pool\Exception\ConnectionException";i:240;s:33:"Hyperf\Pool\LowFrequencyInterface";i:241;s:53:"Hyperf\Process\Listener\LogBeforeProcessStartListener";i:242;s:54:"Hyperf\Process\Listener\LogAfterProcessStoppedListener";i:243;s:43:"Hyperf\Process\Listener\BootProcessListener";i:244;s:33:"Hyperf\Process\Annotation\Process";i:245;s:30:"Hyperf\Process\AbstractProcess";i:246;s:31:"Hyperf\Process\ProcessCollector";i:247;s:29:"Hyperf\Process\ConfigProvider";i:248;s:46:"Hyperf\Process\Exception\SocketAcceptException";i:249;s:47:"Hyperf\Process\Exception\ServerInvalidException";i:250;s:39:"Hyperf\Process\Event\AfterProcessHandle";i:251;s:42:"Hyperf\Process\Event\BeforeCoroutineHandle";i:252;s:41:"Hyperf\Process\Event\AfterCoroutineHandle";i:253;s:32:"Hyperf\Process\Event\PipeMessage";i:254;s:40:"Hyperf\Process\Event\BeforeProcessHandle";i:255;s:29:"Hyperf\Process\ProcessManager";i:256;s:23:"Hyperf\Redis\RedisProxy";i:257;s:28:"Hyperf\Redis\RedisConnection";i:258;s:42:"Hyperf\Redis\Lua\Hash\HIncrByFloatIfExists";i:259;s:37:"Hyperf\Redis\Lua\Hash\HGetAllMultiple";i:260;s:23:"Hyperf\Redis\Lua\Script";i:261;s:32:"Hyperf\Redis\Lua\ScriptInterface";i:262;s:22:"Hyperf\Redis\Frequency";i:263;s:18:"Hyperf\Redis\Redis";i:264;s:25:"Hyperf\Redis\RedisFactory";i:265;s:27:"Hyperf\Redis\ConfigProvider";i:266;s:27:"Hyperf\Redis\Pool\RedisPool";i:267;s:29:"Hyperf\Redis\Pool\PoolFactory";i:268;s:54:"Hyperf\Redis\Exception\InvalidRedisConnectionException";i:269;s:49:"Hyperf\Redis\Exception\InvalidRedisProxyException";i:270;s:45:"Hyperf\Redis\Exception\RedisNotFoundException";i:271;s:18:"Hyperf\Server\Port";i:272;s:19:"Hyperf\Server\Event";i:273;s:46:"Hyperf\Server\Listener\StoreServerNameListener";i:274;s:47:"Hyperf\Server\Listener\InitProcessTitleListener";i:275;s:47:"Hyperf\Server\Listener\AfterWorkerStartListener";i:276;s:20:"Hyperf\Server\Server";i:277;s:26:"Hyperf\Server\Entry\Logger";i:278;s:35:"Hyperf\Server\Entry\EventDispatcher";i:279;s:24:"Hyperf\Server\SwowServer";i:280;s:27:"Hyperf\Server\ServerFactory";i:281;s:25:"Hyperf\Server\SwooleEvent";i:282;s:29:"Hyperf\Server\ServerInterface";i:283;s:33:"Hyperf\Server\Command\StartServer";i:284;s:27:"Hyperf\Server\ServerManager";i:285;s:26:"Hyperf\Server\ServerConfig";i:286;s:33:"Hyperf\Server\SwooleServerFactory";i:287;s:29:"Hyperf\Server\CoroutineServer";i:288;s:28:"Hyperf\Server\ConfigProvider";i:289;s:39:"Hyperf\Server\Exception\ServerException";i:290;s:40:"Hyperf\Server\Exception\RuntimeException";i:291;s:48:"Hyperf\Server\Exception\InvalidArgumentException";i:292;s:44:"Hyperf\Server\Event\MainCoroutineServerStart";i:293;s:39:"Hyperf\Server\Event\CoroutineServerStop";i:294;s:40:"Hyperf\Server\Event\CoroutineServerStart";i:295;s:36:"Hyperf\Utils\Coordinator\Coordinator";i:296;s:43:"Hyperf\Utils\Coordinator\CoordinatorManager";i:297;s:34:"Hyperf\Utils\Coordinator\Constants";i:298;s:41:"Hyperf\Utils\Serializer\SymfonyNormalizer";i:299;s:41:"Hyperf\Utils\Serializer\SerializerFactory";i:300;s:40:"Hyperf\Utils\Serializer\SimpleNormalizer";i:301;s:31:"Hyperf\Utils\ApplicationContext";i:302;s:33:"Hyperf\Utils\Coroutine\Concurrent";i:303;s:29:"Hyperf\Utils\Coroutine\Locker";i:304;s:16:"Hyperf\Utils\Str";i:305;s:19:"Hyperf\Utils\Fluent";i:306;s:31:"Hyperf\Utils\Contracts\Jsonable";i:307;s:32:"Hyperf\Utils\Contracts\Arrayable";i:308;s:30:"Hyperf\Utils\Contracts\Xmlable";i:309;s:33:"Hyperf\Utils\Contracts\MessageBag";i:310;s:38:"Hyperf\Utils\Contracts\MessageProvider";i:311;s:23:"Hyperf\Utils\Codec\Json";i:312;s:22:"Hyperf\Utils\Codec\Xml";i:313;s:25:"Hyperf\Utils\Codec\Base62";i:314;s:30:"Hyperf\Utils\ResourceGenerator";i:315;s:37:"Hyperf\Utils\MimeTypeExtensionGuesser";i:316;s:27:"Hyperf\Utils\ClearStatCache";i:317;s:34:"Hyperf\Utils\Filesystem\Filesystem";i:318;s:45:"Hyperf\Utils\Filesystem\FileNotFoundException";i:319;s:23:"Hyperf\Utils\Pluralizer";i:320;s:30:"Hyperf\Utils\CodeGen\PhpParser";i:321;s:28:"Hyperf\Utils\CodeGen\Package";i:322;s:33:"Hyperf\Utils\CodeGen\PhpDocReader";i:323;s:28:"Hyperf\Utils\CodeGen\Project";i:324;s:40:"Hyperf\Utils\CodeGen\PhpDocReaderManager";i:325;s:19:"Hyperf\Utils\Waiter";i:326;s:21:"Hyperf\Utils\Optional";i:327;s:22:"Hyperf\Utils\Coroutine";i:328;s:27:"Hyperf\Utils\Channel\Caller";i:329;s:35:"Hyperf\Utils\Channel\ChannelManager";i:330;s:21:"Hyperf\Utils\Composer";i:331;s:20:"Hyperf\Utils\Context";i:332;s:39:"Hyperf\Utils\HigherOrderCollectionProxy";i:333;s:20:"Hyperf\Utils\Backoff";i:334;s:23:"Hyperf\Utils\MessageBag";i:335;s:22:"Hyperf\Utils\WaitGroup";i:336;s:21:"Hyperf\Utils\Pipeline";i:337;s:23:"Hyperf\Utils\Collection";i:338;s:23:"Hyperf\Utils\Stringable";i:339;s:20:"Hyperf\Utils\Network";i:340;s:27:"Hyperf\Utils\ConfigProvider";i:341;s:21:"Hyperf\Utils\Resource";i:342;s:24:"Hyperf\Utils\ChannelPool";i:343;s:39:"Hyperf\Utils\Exception\ExceptionThrower";i:344;s:45:"Hyperf\Utils\Exception\ChannelClosedException";i:345;s:43:"Hyperf\Utils\Exception\WaitTimeoutException";i:346;s:47:"Hyperf\Utils\Exception\InvalidArgumentException";i:347;s:49:"Hyperf\Utils\Exception\ParallelExecutionException";i:348;s:39:"Hyperf\Utils\Exception\TimeoutException";i:349;s:21:"Hyperf\Utils\Parallel";i:350;s:16:"Hyperf\Utils\Arr";i:351;s:32:"Hyperf\Utils\HigherOrderTapProxy";i:352;s:36:"Hyperf\Utils\Reflection\ClassInvoker";i:353;s:30:"Hyperf\Utils\Packer\JsonPacker";i:354;s:39:"Hyperf\Utils\Packer\PhpSerializerPacker";i:355;s:53:"Hyperf\WebSocketServer\Listener\OnPipeMessageListener";i:356;s:50:"Hyperf\WebSocketServer\Listener\InitSenderListener";i:357;s:29:"Hyperf\WebSocketServer\Server";i:358;s:40:"Hyperf\WebSocketServer\SenderPipeMessage";i:359;s:44:"Hyperf\WebSocketServer\Collector\FdCollector";i:360;s:35:"Hyperf\WebSocketServer\Collector\Fd";i:361;s:37:"Hyperf\WebSocketServer\CoreMiddleware";i:362;s:30:"Hyperf\WebSocketServer\Context";i:363;s:29:"Hyperf\WebSocketServer\Sender";i:364;s:31:"Hyperf\WebSocketServer\Security";i:365;s:37:"Hyperf\WebSocketServer\ConfigProvider";i:366;s:58:"Hyperf\WebSocketServer\Exception\WebSocketMessageException";i:367;s:66:"Hyperf\WebSocketServer\Exception\Handler\WebSocketExceptionHandler";i:368;s:55:"Hyperf\WebSocketServer\Exception\InvalidMethodException";i:369;s:61:"Hyperf\WebSocketServer\Exception\WebSocketHandeShakeException";i:370;s:40:"Hyperf\WebSocketServer\Event\OnOpenEvent";i:371;s:19:"Hyperf\Devtool\Info";i:372;s:35:"Hyperf\Devtool\VendorPublishCommand";i:373;s:26:"Hyperf\Devtool\InfoCommand";i:374;s:30:"Hyperf\Devtool\Adapter\Aspects";i:375;s:38:"Hyperf\Devtool\Adapter\AbstractAdapter";i:376;s:38:"Hyperf\Devtool\Describe\AspectsCommand";i:377;s:40:"Hyperf\Devtool\Describe\ListenersCommand";i:378;s:37:"Hyperf\Devtool\Describe\RoutesCommand";i:379;s:44:"Hyperf\Devtool\Generator\NatsConsumerCommand";i:380;s:44:"Hyperf\Devtool\Generator\AmqpConsumerCommand";i:381;s:40:"Hyperf\Devtool\Generator\ResourceCommand";i:382;s:44:"Hyperf\Devtool\Generator\AmqpProducerCommand";i:383;s:35:"Hyperf\Devtool\Generator\JobCommand";i:384;s:40:"Hyperf\Devtool\Generator\ConstantCommand";i:385;s:38:"Hyperf\Devtool\Generator\AspectCommand";i:386;s:39:"Hyperf\Devtool\Generator\RequestCommand";i:387;s:42:"Hyperf\Devtool\Generator\ControllerCommand";i:388;s:45:"Hyperf\Devtool\Generator\KafkaConsumerCommand";i:389;s:39:"Hyperf\Devtool\Generator\CommandCommand";i:390;s:41:"Hyperf\Devtool\Generator\GeneratorCommand";i:391;s:43:"Hyperf\Devtool\Generator\NsqConsumerCommand";i:392;s:40:"Hyperf\Devtool\Generator\ListenerCommand";i:393;s:39:"Hyperf\Devtool\Generator\ProcessCommand";i:394;s:42:"Hyperf\Devtool\Generator\MiddlewareCommand";i:395;s:29:"Hyperf\Devtool\ConfigProvider";i:396;s:36:"App\Listener\DbQueryExecutedListener";i:397;s:14:"App\Utils\guid";i:398;s:14:"App\Utils\Http";i:399;s:17:"App\Utils\HashMap";i:400;s:34:"App\Controller\WebsocketController";i:401;s:27:"App\Service\TransferService";i:402;s:41:"App\Exception\Handler\AppExceptionHandler";} |
New file |
| | |
| | | <?php |
| | | |
| | | /* |
| | | * @Author: your name |
| | | * @Date: 2021-12-24 10:26:10 |
| | | * @LastEditTime: 2021-12-24 17:11:44 |
| | | * @LastEditors: Please set LastEditors |
| | | * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE |
| | | * @FilePath: /hy-websocket/app/Controller/WebsocketController.php |
| | | */ |
| | | declare (strict_types=1); |
| | | namespace App\Controller; |
| | | |
| | | use Hyperf\Contract\OnCloseInterface; |
| | | use Hyperf\Contract\OnMessageInterface; |
| | | use Hyperf\Contract\OnOpenInterface; |
| | | use Hyperf\Contract\OnHandShakeInterface; |
| | | use Hyperf\Utils\Codec\Json; |
| | | use Swoole\Http\Request; |
| | | use Swoole\Http\Response; |
| | | use Swoole\WebSocket\Frame; |
| | | use Swoole\WebSocket\Server; |
| | | use Hyperf\Redis\Redis; |
| | | use Hyperf\Di\Annotation\Inject; |
| | | use Hyperf\Config\Annotation\Value; |
| | | use App\Utils\guid; |
| | | use App\Utils\HashMap; |
| | | use App\Utils\Http; |
| | | use App\Utils\PcmToWave; |
| | | use App\Service\TransferService; |
| | | use Psr\Container\ContainerInterface; |
| | | use Hyperf\Logger\LoggerFactory; |
| | | use Hyperf\Contract\ConfigInterface; |
| | | class WebsocketController implements OnMessageInterface, OnOpenInterface, OnCloseInterface |
| | | { |
| | | use \Hyperf\Di\Aop\ProxyTrait; |
| | | use \Hyperf\Di\Aop\PropertyHandlerTrait; |
| | | /** |
| | | * @Inject |
| | | * @var TransferService |
| | | */ |
| | | private $transferService; |
| | | /** |
| | | * |
| | | * @Inject |
| | | * @var HashMap |
| | | */ |
| | | private $HashMap; |
| | | //存放音频写入句柄 |
| | | /** |
| | | * |
| | | * @var \Psr\Log\LoggerInterface |
| | | */ |
| | | public $logger; |
| | | /** |
| | | * @Inject() |
| | | * @var ConfigInterface |
| | | */ |
| | | private $config; |
| | | private $server_config; |
| | | private $allow_ip; |
| | | public function __construct(LoggerFactory $loggerFactory) |
| | | { |
| | | $this->__handlePropertyHandler(__CLASS__); |
| | | // 第一个参数对应日志的 name, 第二个参数对应 config/autoload/logger.php 内的 key |
| | | $this->logger = $loggerFactory->get('log', 'default'); |
| | | //获取 server.php 里的内容 |
| | | $this->server_config = $this->config->get('server.servers', ''); |
| | | $this->allow_ip = $this->server_config[0]['allow_ip']; |
| | | } |
| | | public function onClose($server, int $fd, int $reactorId) : void |
| | | { |
| | | //客户端异常关闭 |
| | | //语音文件传输完毕,关闭文件。 |
| | | $host = $this->allow_ip; |
| | | $group_key = $this->transferService->get($host . ':' . $fd . ':group'); |
| | | $this->transferService->lrem($group_key, $fd, 0); |
| | | $set_ket = $host . ':' . $fd . ':group'; |
| | | $this->transferService->delete($set_ket); |
| | | } |
| | | public function onStart($server) : void |
| | | { |
| | | $host = $this->allow_ip; |
| | | $keyList = $this->transferService->keys("*{$host}*"); |
| | | foreach ($keyList as $key => $value) { |
| | | $this->transferService->delete($value); |
| | | } |
| | | } |
| | | /** |
| | | * @param Response|Server $server |
| | | */ |
| | | public function onMessage($server, Frame $frame) : void |
| | | { |
| | | $ret = array('code' => 0, 'data' => null); |
| | | $msgData = $this->is_json($frame->data, true); |
| | | if ($msgData) { |
| | | $frameData = $msgData; |
| | | $url = $frameData['url']; |
| | | $data = $frameData['data']; |
| | | $action = substr($url, strrpos($url, "/") + 1); |
| | | switch ($action) { |
| | | case "reg": |
| | | $groupId = $data['group_id']; |
| | | $session = $data['session_id']; |
| | | $this->bind($groupId, '', $frame->fd); |
| | | $key = "practice_scenes_ws_cur_session_info:" . $session; |
| | | $node_key = 'practice_scenes_ws_cur_session_node_info:' . $session; |
| | | $redisData = $this->transferService->get($key); |
| | | if ($redisData) { |
| | | $ret['data'] = json_decode($redisData, true); |
| | | $this->transferService->delete($key); |
| | | } else { |
| | | $redisData = $this->transferService->get($node_key); |
| | | if ($redisData) { |
| | | $ret['data'] = json_decode($redisData, true); |
| | | } else { |
| | | $ret['data'] = ''; |
| | | } |
| | | } |
| | | $ret['event'] = "re_bind"; |
| | | $server->push($frame->fd, json_encode($ret)); |
| | | break; |
| | | case "data": |
| | | $groupId = $data['group_id']; |
| | | $ret['event'] = "data"; |
| | | $ret['data'] = $data; |
| | | $connections = array(); |
| | | if (empty($groupId)) { |
| | | // 获取所有无分组标识在线终端 |
| | | $onlines = count($server->connections); |
| | | if ($onlines > 0) { |
| | | $connections = $server->connections; |
| | | } |
| | | } else { |
| | | // 获取所有分组标识在线终端 key = groupID:host |
| | | $key = $groupId . ':' . $this->allow_ip; |
| | | $connections = $this->transferService->lrange($key, 0, -1); |
| | | } |
| | | $connections = array_unique($connections); |
| | | // 广播获取的在线终端 |
| | | foreach ($connections as $fd) { |
| | | $ingfd = (int) $fd; |
| | | $server->push($ingfd, json_encode($ret)); |
| | | } |
| | | break; |
| | | case "ping": |
| | | $server->push($frame->fd, $data . 'pong'); |
| | | break; |
| | | default: |
| | | $ret['code'] = 404; |
| | | $ret['msg'] = 'event no existent'; |
| | | $server->push($frame->fd, json_encode($ret)); |
| | | return; |
| | | } |
| | | } else { |
| | | $ret['code'] = -1; |
| | | $ret['msg'] = 'data is null or data no json'; |
| | | $server->push($frame->fd, json_encode($ret)); |
| | | return; |
| | | } |
| | | } |
| | | public function onOpen($server, Request $request) : void |
| | | { |
| | | // $server->push($request->fd, 'Opened'); |
| | | // var_dump($request); |
| | | } |
| | | /** |
| | | * 功能:1、判断是否是json |
| | | * @param string $data |
| | | * @param bool $assoc |
| | | * @return bool|mixed|string |
| | | */ |
| | | public function is_json($data = '', $assoc = false) |
| | | { |
| | | $data = json_decode($data, $assoc); |
| | | if ($data && is_object($data) || is_array($data) && !empty(current($data))) { |
| | | return $data; |
| | | } |
| | | return false; |
| | | } |
| | | /** |
| | | * 当前链接的绑定事件。 |
| | | * 绑定的几种状态: |
| | | * 1.无分组 |
| | | * host -> fds (获取当前节点的在线链接列表) |
| | | * host:fd -> value (获取当前节点当前链接的绑定数据) |
| | | * host:fd:group -> host (获取当前节点当前链接的绑定分组) |
| | | * 2.有分组 |
| | | * groupID:host -> fds |
| | | * host:fd -> value |
| | | * host:fd:group -> groupID:host |
| | | * @param string $groupID 需要绑定当前链接所在分组的分组标识,如果为空则使用默认分组 |
| | | * @param string $value 需要绑定当前链接对应的业务数据,如果为空则不绑定 |
| | | */ |
| | | public function bind($groupID = '', $value = '', $fd) |
| | | { |
| | | $host = $this->allow_ip; |
| | | // 绑定分组和当前链接对应的分组标识 |
| | | if (empty($groupID)) { |
| | | $this->transferService->rpush($host, $fd); |
| | | $this->transferService->set($host . ':' . $fd . ':group', $host); |
| | | } else { |
| | | $this->transferService->rpush($groupID . ':' . $host, $fd); |
| | | $this->transferService->set($host . ':' . $fd . ':group', $groupID . ':' . $host); |
| | | } |
| | | // 绑定业务数据 |
| | | if (!empty($value)) { |
| | | $this->transferService->set($host . ':' . $fd, $value); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | <?php |
| | | |
| | | namespace App\Service; |
| | | |
| | | use Hyperf\Redis\Redis; |
| | | use Hyperf\Di\Annotation\Inject; |
| | | use Hyperf\Config\Annotation\Value; |
| | | use App\Utils\Http; |
| | | class TransferService extends Http |
| | | { |
| | | use \Hyperf\Di\Aop\ProxyTrait; |
| | | use \Hyperf\Di\Aop\PropertyHandlerTrait; |
| | | function __construct() |
| | | { |
| | | if (method_exists(parent::class, '__construct')) { |
| | | parent::__construct(...func_get_args()); |
| | | } |
| | | $this->__handlePropertyHandler(__CLASS__); |
| | | } |
| | | /** |
| | | * |
| | | * @Inject |
| | | * @var Redis |
| | | */ |
| | | private $redis; |
| | | public function ping() |
| | | { |
| | | $result = $this->redis->ping(); |
| | | } |
| | | public function setnx($strKey, $value) |
| | | { |
| | | $this->redis->setnx($strKey, $value); |
| | | } |
| | | public function set($strKey, $value) |
| | | { |
| | | $this->redis->set($strKey, $value); |
| | | } |
| | | public function get($strKey) |
| | | { |
| | | return $this->redis->get($strKey); |
| | | } |
| | | public function delete($strKey) |
| | | { |
| | | $this->redis->del($strKey); |
| | | } |
| | | public function incrby($str_key, $value = 0) |
| | | { |
| | | $this->redis->incrby($str_key, $value); |
| | | } |
| | | public function incr($fd) |
| | | { |
| | | return $this->redis->incr($fd); |
| | | } |
| | | public function decr($strKey) |
| | | { |
| | | return $this->redis->decr($strKey); |
| | | } |
| | | public function decrby($strKey, $num) |
| | | { |
| | | return $this->redis->decrby($strKey, $num); |
| | | } |
| | | public function lSize($strKey) |
| | | { |
| | | return $this->redis->lSize($strKey); |
| | | } |
| | | public function lGet($strKey, $index) |
| | | { |
| | | return $this->redis->lGet($strKey, $index); |
| | | } |
| | | public function lrem($strKey, $value, $index) |
| | | { |
| | | return $this->redis->lrem($strKey, $value, $index); |
| | | } |
| | | public function lPush($strKey, $value) |
| | | { |
| | | $this->redis->lPush($strKey, $value); |
| | | } |
| | | public function rPush($strKey, $value) |
| | | { |
| | | $this->redis->rPush($strKey, $value); |
| | | } |
| | | public function lPop($strKey) |
| | | { |
| | | return $this->redis->lPop($strKey); |
| | | } |
| | | public function rPop($strKey) |
| | | { |
| | | return $this->redis->rPop($strKey); |
| | | } |
| | | public function lSet($strKey, $index, $value) |
| | | { |
| | | return $this->redis->lSet($strKey, $index, $value); |
| | | } |
| | | public function lrange($strKey, $index, $length) |
| | | { |
| | | return $this->redis->lrange($strKey, $index, $length); |
| | | } |
| | | public function keys($strKey) |
| | | { |
| | | return $this->redis->keys($strKey); |
| | | } |
| | | } |
New file |
| | |
| | | <?php |
| | | |
| | | namespace App\Utils; |
| | | |
| | | use GuzzleHttp\Client; |
| | | use GuzzleHttp\HandlerStack; |
| | | use Hyperf\Guzzle\CoroutineHandler; |
| | | use GuzzleHttp\Exception\ClientException; |
| | | use Hyperf\Di\Annotation\Inject; |
| | | use Hyperf\Guzzle\ClientFactory; |
| | | class Http |
| | | { |
| | | use \Hyperf\Di\Aop\ProxyTrait; |
| | | use \Hyperf\Di\Aop\PropertyHandlerTrait; |
| | | function __construct() |
| | | { |
| | | $this->__handlePropertyHandler(__CLASS__); |
| | | } |
| | | /** |
| | | * @Inject |
| | | * @var ClientFactory |
| | | */ |
| | | private $clientFactory; |
| | | function get_host($url, &$path) |
| | | { |
| | | $pos = strpos($url, "/", 8); |
| | | if (!$pos) { |
| | | $path = "/"; |
| | | return $url; |
| | | } |
| | | $path = substr($url, $pos); |
| | | return substr($url, 0, $pos); |
| | | } |
| | | public function get_content_length($url, $time_out = 60) |
| | | { |
| | | if ($url == "") { |
| | | return 0; |
| | | } |
| | | try { |
| | | $options = ['base_uri' => "", 'handler' => HandlerStack::create(new CoroutineHandler()), 'timeout' => $time_out, 'swoole' => ['timeout' => $time_out, 'socket_buffer_size' => 1024 * 1024 * 2]]; |
| | | $path = ""; |
| | | $host = $this->get_host($url, $path); |
| | | if ($host == "") { |
| | | return 0; |
| | | } |
| | | $options["base_uri"] = $host; |
| | | $client = $this->clientFactory->create($options); |
| | | $response = $client->get($path); |
| | | if ($response->getStatusCode() != 200) { |
| | | return 0; |
| | | } |
| | | $str_size = $response->getHeader('Content-Length'); |
| | | $size = intval($str_size[0]); |
| | | return $size; |
| | | } catch (ClientException $e) { |
| | | //获取协程中出现的异常。 |
| | | $response_e = $e->getResponse(); |
| | | } |
| | | return 0; |
| | | } |
| | | public function get_web_result($url, $time_out = 10) |
| | | { |
| | | if ($url == "") { |
| | | return ""; |
| | | } |
| | | $path = ""; |
| | | $host = $this->get_host($url, $path); |
| | | if ($host == "") { |
| | | return ""; |
| | | } |
| | | $options = ['base_uri' => $host, 'handler' => HandlerStack::create(new CoroutineHandler()), 'timeout' => $time_out, 'swoole' => ['timeout' => $time_out, 'socket_buffer_size' => 1024 * 1024 * 2]]; |
| | | try { |
| | | //var_dump($this->clientFactory); |
| | | $client = $this->clientFactory->create($options); |
| | | $response = $client->get($path); |
| | | if ($response->getStatusCode() == 200) { |
| | | $strContent = $response->getBody()->getContents(); |
| | | //echo "$strContent\r\n"; |
| | | return $strContent; |
| | | } |
| | | } catch (ClientException $e) { |
| | | //获取协程中出现的异常。 |
| | | var_dump($e->getResponse()); |
| | | } |
| | | return ""; |
| | | } |
| | | public function post_web_result($url, $post_data, $time_out = 10) |
| | | { |
| | | if ($url == "") { |
| | | return ""; |
| | | } |
| | | $path = ""; |
| | | $host = $this->get_host($url, $path); |
| | | if ($host == "") { |
| | | return ""; |
| | | } |
| | | $options = ['base_uri' => $host, 'handler' => HandlerStack::create(new CoroutineHandler()), 'timeout' => $time_out, 'swoole' => ['timeout' => $time_out, 'socket_buffer_size' => 1024 * 1024 * 2]]; |
| | | try { |
| | | $client = $this->clientFactory->create($options); |
| | | $response = $client->request('POST', $url, ['form_params' => $post_data]); |
| | | //debug |
| | | //$response = $client->request('POST', $url, ['form_params' => $post_data,'debug' => true]); |
| | | if ($response->getStatusCode() == 200) { |
| | | $strContent = $response->getBody()->getContents(); |
| | | //echo "$strContent\r\n"; |
| | | return $strContent; |
| | | } |
| | | } catch (ClientException $e) { |
| | | //获取协程中出现的异常。 |
| | | //var_dump($e->getResponse()); |
| | | } |
| | | return ""; |
| | | } |
| | | public function post_json_result($url, $post_data, $time_out = 10) |
| | | { |
| | | if ($url == "") { |
| | | return ""; |
| | | } |
| | | $path = ""; |
| | | $host = $this->get_host($url, $path); |
| | | if ($host == "") { |
| | | return ""; |
| | | } |
| | | $options = ['base_uri' => $host, 'handler' => HandlerStack::create(new CoroutineHandler()), 'timeout' => $time_out, 'swoole' => ['timeout' => $time_out, 'socket_buffer_size' => 1024 * 1024 * 2]]; |
| | | try { |
| | | $client = $this->clientFactory->create($options); |
| | | if (is_array($post_data)) { |
| | | $response = $client->request('POST', $url, ['body' => json_encode($post_data), "headers" => ['Accept' => 'application/json']]); |
| | | } else { |
| | | $response = $client->request('POST', $url, ['body' => $post_data, "headers" => ['Accept' => 'application/json']]); |
| | | } |
| | | //debug |
| | | //$response = $client->request('POST', $url, ['form_params' => $post_data,'debug' => true]); |
| | | if ($response->getStatusCode() == 200) { |
| | | $strContent = $response->getBody()->getContents(); |
| | | //echo "$strContent\r\n"; |
| | | return $strContent; |
| | | } |
| | | } catch (ClientException $e) { |
| | | //获取协程中出现的异常。 |
| | | var_dump($e->getResponse()); |
| | | } |
| | | return ""; |
| | | } |
| | | } |
New file |
| | |
| | | a:2:{i:0;a:3:{s:35:"Hyperf\Cache\CacheListenerCollector";s:6:"a:0:{}";s:40:"Hyperf\Di\Annotation\AnnotationCollector";s:4640:"a:25:{s:36:"Hyperf\Cache\Aspect\CacheEvictAspect";a:1:{s:2:"_c";a:1:{s:27:"Hyperf\Di\Annotation\Aspect";O:27:"Hyperf\Di\Annotation\Aspect":3:{s:7:"classes";a:0:{}s:11:"annotations";a:0:{}s:8:"priority";N;}}}s:35:"Hyperf\Cache\Aspect\CacheableAspect";a:1:{s:2:"_c";a:1:{s:27:"Hyperf\Di\Annotation\Aspect";O:27:"Hyperf\Di\Annotation\Aspect":3:{s:7:"classes";a:0:{}s:11:"annotations";a:0:{}s:8:"priority";N;}}}s:34:"Hyperf\Cache\Aspect\CachePutAspect";a:1:{s:2:"_c";a:1:{s:27:"Hyperf\Di\Annotation\Aspect";O:27:"Hyperf\Di\Annotation\Aspect":3:{s:7:"classes";a:0:{}s:11:"annotations";a:0:{}s:8:"priority";N;}}}s:35:"Hyperf\Cache\Aspect\FailCacheAspect";a:1:{s:2:"_c";a:1:{s:27:"Hyperf\Di\Annotation\Aspect";O:27:"Hyperf\Di\Annotation\Aspect":3:{s:7:"classes";a:0:{}s:11:"annotations";a:0:{}s:8:"priority";N;}}}s:35:"Hyperf\Devtool\VendorPublishCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:26:"Hyperf\Devtool\InfoCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:44:"Hyperf\Devtool\Generator\NatsConsumerCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:44:"Hyperf\Devtool\Generator\AmqpConsumerCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:40:"Hyperf\Devtool\Generator\ResourceCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:44:"Hyperf\Devtool\Generator\AmqpProducerCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:35:"Hyperf\Devtool\Generator\JobCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:40:"Hyperf\Devtool\Generator\ConstantCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:38:"Hyperf\Devtool\Generator\AspectCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:39:"Hyperf\Devtool\Generator\RequestCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:42:"Hyperf\Devtool\Generator\ControllerCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:45:"Hyperf\Devtool\Generator\KafkaConsumerCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:39:"Hyperf\Devtool\Generator\CommandCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:43:"Hyperf\Devtool\Generator\NsqConsumerCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:40:"Hyperf\Devtool\Generator\ListenerCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:39:"Hyperf\Devtool\Generator\ProcessCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:42:"Hyperf\Devtool\Generator\MiddlewareCommand";a:1:{s:2:"_c";a:1:{s:33:"Hyperf\Command\Annotation\Command";O:33:"Hyperf\Command\Annotation\Command":0:{}}}s:36:"App\Listener\DbQueryExecutedListener";a:1:{s:2:"_c";a:1:{s:32:"Hyperf\Event\Annotation\Listener";O:32:"Hyperf\Event\Annotation\Listener":1:{s:8:"priority";i:1;}}}s:14:"App\Utils\Http";a:1:{s:2:"_p";a:1:{s:13:"clientFactory";a:1:{s:27:"Hyperf\Di\Annotation\Inject";O:27:"Hyperf\Di\Annotation\Inject":3:{s:5:"value";s:27:"Hyperf\Guzzle\ClientFactory";s:8:"required";b:1;s:4:"lazy";b:0;}}}}s:27:"App\Service\TransferService";a:1:{s:2:"_p";a:1:{s:5:"redis";a:1:{s:27:"Hyperf\Di\Annotation\Inject";O:27:"Hyperf\Di\Annotation\Inject":3:{s:5:"value";s:18:"Hyperf\Redis\Redis";s:8:"required";b:1;s:4:"lazy";b:0;}}}}s:34:"App\Controller\WebsocketController";a:1:{s:2:"_p";a:3:{s:15:"transferService";a:1:{s:27:"Hyperf\Di\Annotation\Inject";O:27:"Hyperf\Di\Annotation\Inject":3:{s:5:"value";s:27:"App\Service\TransferService";s:8:"required";b:1;s:4:"lazy";b:0;}}s:7:"HashMap";a:1:{s:27:"Hyperf\Di\Annotation\Inject";O:27:"Hyperf\Di\Annotation\Inject":3:{s:5:"value";s:17:"App\Utils\HashMap";s:8:"required";b:1;s:4:"lazy";b:0;}}s:6:"config";a:1:{s:27:"Hyperf\Di\Annotation\Inject";O:27:"Hyperf\Di\Annotation\Inject":3:{s:5:"value";s:31:"Hyperf\Contract\ConfigInterface";s:8:"required";b:1;s:4:"lazy";b:0;}}}}}";s:36:"Hyperf\Di\Annotation\AspectCollector";s:1856:"a:2:{i:0;a:6:{s:36:"Hyperf\Cache\Aspect\CacheEvictAspect";a:3:{s:8:"priority";i:0;s:7:"classes";a:0:{}s:11:"annotations";a:1:{i:0;s:34:"Hyperf\Cache\Annotation\CacheEvict";}}s:35:"Hyperf\Cache\Aspect\CacheableAspect";a:3:{s:8:"priority";i:0;s:7:"classes";a:0:{}s:11:"annotations";a:1:{i:0;s:33:"Hyperf\Cache\Annotation\Cacheable";}}s:34:"Hyperf\Cache\Aspect\CachePutAspect";a:3:{s:8:"priority";i:0;s:7:"classes";a:0:{}s:11:"annotations";a:1:{i:0;s:32:"Hyperf\Cache\Annotation\CachePut";}}s:35:"Hyperf\Cache\Aspect\FailCacheAspect";a:3:{s:8:"priority";i:0;s:7:"classes";a:0:{}s:11:"annotations";a:1:{i:0;s:33:"Hyperf\Cache\Annotation\FailCache";}}s:36:"Hyperf\Config\Annotation\ValueAspect";a:3:{s:8:"priority";i:0;s:7:"classes";a:0:{}s:11:"annotations";a:1:{i:0;s:30:"Hyperf\Config\Annotation\Value";}}s:33:"Hyperf\Di\Annotation\InjectAspect";a:3:{s:8:"priority";i:0;s:7:"classes";a:0:{}s:11:"annotations";a:1:{i:0;s:27:"Hyperf\Di\Annotation\Inject";}}}i:1;a:2:{s:7:"classes";a:6:{s:36:"Hyperf\Cache\Aspect\CacheEvictAspect";a:0:{}s:35:"Hyperf\Cache\Aspect\CacheableAspect";a:0:{}s:34:"Hyperf\Cache\Aspect\CachePutAspect";a:0:{}s:35:"Hyperf\Cache\Aspect\FailCacheAspect";a:0:{}s:36:"Hyperf\Config\Annotation\ValueAspect";a:0:{}s:33:"Hyperf\Di\Annotation\InjectAspect";a:0:{}}s:11:"annotations";a:6:{s:36:"Hyperf\Cache\Aspect\CacheEvictAspect";a:1:{i:0;s:34:"Hyperf\Cache\Annotation\CacheEvict";}s:35:"Hyperf\Cache\Aspect\CacheableAspect";a:1:{i:0;s:33:"Hyperf\Cache\Annotation\Cacheable";}s:34:"Hyperf\Cache\Aspect\CachePutAspect";a:1:{i:0;s:32:"Hyperf\Cache\Annotation\CachePut";}s:35:"Hyperf\Cache\Aspect\FailCacheAspect";a:1:{i:0;s:33:"Hyperf\Cache\Annotation\FailCache";}s:36:"Hyperf\Config\Annotation\ValueAspect";a:1:{i:0;s:30:"Hyperf\Config\Annotation\Value";}s:33:"Hyperf\Di\Annotation\InjectAspect";a:1:{i:0;s:27:"Hyperf\Di\Annotation\Inject";}}}}";}i:1;a:3:{s:14:"App\Utils\Http";s:98:"/Users/xunniao001/Documents/zhou/git/hy-websocket/runtime/container/proxy/App_Utils_Http.proxy.php";s:34:"App\Controller\WebsocketController";s:118:"/Users/xunniao001/Documents/zhou/git/hy-websocket/runtime/container/proxy/App_Controller_WebsocketController.proxy.php";s:27:"App\Service\TransferService";s:111:"/Users/xunniao001/Documents/zhou/git/hy-websocket/runtime/container/proxy/App_Service_TransferService.proxy.php";}} |