composer安装WebSocket服务:
composer require hyperf/websocket-server
在配置文件 config/autoload/server.php 文件中,servers下添加WebSocket服务配置,如下:
-
'servers' => [
-
[
-
'name' =>
'http',
-
'type' => Server::SERVER_HTTP,
-
'host' =>
'0.0.0.0',
-
'port' =>
9501,
-
'sock_type' => SWOOLE_SOCK_TCP,
-
'callbacks' => [
-
Event::ON_REQUEST => [Hyperf\HttpServer\Server::class,
'onRequest'],
-
],
-
],
-
[
-
'name' =>
'ws',
-
'type' => Server::SERVER_WEBSOCKET,
-
'host' =>
'0.0.0.0',
-
'port' =>
9502,
-
'soc
转载:https://blog.csdn.net/msllws/article/details/114269271
查看评论