Skip to content

woodylan/go-websocket-php-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-websocket 项目的PHP版SDK

go-websocket 项目地址:https://github.com/woodylan/go-websocket

安装

Composer

composer require woodylan/go-websocket-php-sdk

使用

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

接口列表

  1. 注册系统

    $wsServer->register($systemId);
  2. 发送给指定clientId

    $wsServer->sendToClientId($systemId, $clientId, $sendUserId, $code, $msg, $data);
  3. 发送给指定clientIds

    $wsServer->sendToClientIds($systemId, $clientIds, $sendUserId, $code, $msg, $data);
  4. 绑定clientId到分组

    $wsServer->bindToGroup($systemId, $groupName, $clientId, $userId = '');
  5. 发送消息给指定分组

    $wsServer->sendToGroup($systemId, $groupName, $sendUserId, $code, $msg, $data);
  6. 获取在线客户端列表

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