PHP code example of lessmore92 / swoole-websocket-client
1. Go to this page and download the library: Download lessmore92/swoole-websocket-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lessmore92 / swoole-websocket-client example snippets
use Lessmore92\Swoole\WebSocketClient;
use function Co\run;
t('wss://socket.MyFancyApp.io:2053/app/app-key?protocol=7&client=js&version=7.0.6&flash=false');
$webSocketClient->push('{"event":"pusher:subscribe","data":{"auth":"","channel":"msgs"}}');
$webSocketClient->recv();
while ($webSocketClient->client->connected)
{
$data = $webSocketClient->recv();
var_dump($data);
}
});