小言_互联网的博客

Hyperf-高性能PHP协程框架实战(七) WebSocket 服务

322人阅读  评论(0)

      composer安装WebSocket服务:

composer require hyperf/websocket-server

      在配置文件 config/autoload/server.php 文件中,servers下添加WebSocket服务配置,如下:


  
  1. 'servers' => [
  2. [
  3. 'name' => 'http',
  4. 'type' => Server::SERVER_HTTP,
  5. 'host' => '0.0.0.0',
  6. 'port' => 9501,
  7. 'sock_type' => SWOOLE_SOCK_TCP,
  8. 'callbacks' => [
  9. Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'],
  10. ],
  11. ],
  12. [
  13. 'name' => 'ws',
  14. 'type' => Server::SERVER_WEBSOCKET,
  15. 'host' => '0.0.0.0',
  16. 'port' => 9502,
  17. 'soc

转载:https://blog.csdn.net/msllws/article/details/114269271
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场