PHP code example of woodylan / go-websocket-php-sdk

1. Go to this page and download the library: Download woodylan/go-websocket-php-sdk 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/ */

    

woodylan / go-websocket-php-sdk example snippets


// 导入类
use Woodylan\Websocket\WsServer;
// 实例化
$wsServer = new WsServer('https://ws.example.com', '660');
// 例子 注册系统
$wsServer->register('xxxxx');

   $wsServer->register($systemId);
   

   $wsServer->sendToClientId($systemId, $clientId, $sendUserId, $code, $msg, $data);
   

   $wsServer->sendToClientIds($systemId, $clientIds, $sendUserId, $code, $msg, $data);
   

   $wsServer->bindToGroup($systemId, $groupName, $clientId, $userId = '');
   

   $wsServer->sendToGroup($systemId, $groupName, $sendUserId, $code, $msg, $data);
   

   $wsServer->getOnlineList($systemId, $groupName = '');