k8s / ws-ratchet
基于 Ratchet 的 k8s/client 的 websocket 适配器
1.1.1
2021-12-11 21:04 UTC
Requires
- php: >=7.2
- k8s/core: ^1.3
- ratchet/pawl: ^0.3|^0.4
Requires (Dev)
- ext-mbstring: *
- friendsofphp/php-cs-fixer: ^2.0
- mockery/mockery: ~1.3.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^8.0
README
此库为 k8s/client
库提供了一个基于 Ratchet 的 websocket 适配器。
通用 K8s 库用法/配置选项
- 安装库
composer require k8s/ws-ratchet
注意:如果您不需要更改任何 TLS 设置,那么这就足够了。
- 如果您需要配置任何选项,则可以使用以下方法设置这些选项,并使用 websocket 与它们一起使用
use K8s\Client\K8s; use K8s\Client\Options; use K8s\WsRatchet\RatchetWebsocketAdapter; $options = [ # Set a timeout for the websocket connection 'timeout' => 15, # Can toggle these to false if you are using a self-signed cert 'tls' => [ 'verify_peer' => true, 'verify_peer_name' => true, ], ]; $websocket = new RatchetWebsocketAdapter($options); # You can then pass the new websocket adapter in the options to be used $options = new Options('k8s.endpoint.local'); $options->setWebsocketClient($websocket); # Construct K8s to use the new websocket in the options $k8s = new K8s($options);