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');
-
注册系统
$wsServer->register($systemId);
-
发送给指定clientId
$wsServer->sendToClientId($systemId, $clientId, $sendUserId, $code, $msg, $data);
-
发送给指定clientIds
$wsServer->sendToClientIds($systemId, $clientIds, $sendUserId, $code, $msg, $data);
-
绑定clientId到分组
$wsServer->bindToGroup($systemId, $groupName, $clientId, $userId = '');
-
发送消息给指定分组
$wsServer->sendToGroup($systemId, $groupName, $sendUserId, $code, $msg, $data);
-
获取在线客户端列表
$wsServer->getOnlineList($systemId, $groupName = '');