PHPackages                             ledc/websocket - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. ledc/websocket

ActiveLibrary[HTTP &amp; Networking](/categories/http)

ledc/websocket
==============

Su WebSocket是一个go语言编写的高性能WebSocket服务器，支持客户端连接管理、UID管理、群组管理、消息推送、RPC调用等功能；完全参考GatewayWorker设计的HTTP管理API接口。

v8.3.6(6mo ago)19MITGoPHP &gt;=8.3

Since Sep 17Pushed 5mo agoCompare

[ Source](https://github.com/ledccn/suws-php-sdk)[ Packagist](https://packagist.org/packages/ledc/websocket)[ RSS](/packages/ledc-websocket/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

Su WebSocket服务
==============

[](#su-websocket服务)

Su WebSocket是一个go语言编写的高性能WebSocket服务器，支持客户端连接管理、UID管理、群组管理、消息推送、RPC调用等功能；

完全参考GatewayWorker设计的HTTP管理API接口。

安装 Installation
---------------

[](#安装-installation)

```
composer require ledc/websocket
```

运行环境
----

[](#运行环境)

PHP版本：&gt;=8.3

接口文档
----

[](#接口文档)

快速开始 Quick Start
----------------

[](#快速开始-quick-start)

可以在 `.env` 文件中配置环境变量

```
SUWS_TOKEN=管理令牌（与SUWS服务端配置一致）
SUWS_URL=http://127.0.0.1:8788/api
SUWS_TIMEOUT=5

```

或者通过函数设置环境变量：

```
\Ledc\Websocket\suws_set_env('管理Token', 'http://127.0.0.1:8788/api', 5);
```

然后，使用单例模式调用：

```
use Ledc\Websocket\SuWS;

// 向所有客户端或者指定的客户端发送数据
$result = SuWS::getInstance()->sendToAll();

// 向指定的客户端发送数据
$result = SuWS::getInstance()->sendToClient();

// 关闭指定的客户端的连接
$result = SuWS::getInstance()->closeClient();

// 判断指定客户端是否在线
$result = SuWS::getInstance()->isOnline();

// 获取ClientId会话信息
$result = SuWS::getInstance()->getSession();

// 设置ClientId会话信息
$result = SuWS::getInstance()->setSession();

// 获取所有在线ClientId总数量
$result = SuWS::getInstance()->getAllClientIdCount();
$result = SuWS::getInstance()->getAllClientCount();

// 获取所有在线ClientId列表
$result = SuWS::getInstance()->getAllClientIdList();

// 获取所有在线Client会话信息
$result = SuWS::getInstance()->getAllClientSessions();

// 将client_id与uid绑定
$result = SuWS::getInstance()->bindUid();

// 解除client_id与uid的绑定
$result = SuWS::getInstance()->unbindUid();

// 判断用户是否在线
$result = SuWS::getInstance()->isUidOnline();

// 发送消息给指定UID
$result = SuWS::getInstance()->sendToUid();

// 通过UID获取ClientIds
$result = SuWS::getInstance()->getClientIdByUid();

// 通过ClientId获取UID
$result = SuWS::getInstance()->getUidByClientId();

// 获取所有在线UID列表
$result = SuWS::getInstance()->getAllUidList();

// 获取所有在线UID总数量
$result = SuWS::getInstance()->getAllUidCount();

// 获取UID会话信息
$result = SuWS::getInstance()->getUidSession();

// 设置UID会话信息
$result = SuWS::getInstance()->setUidSession();

// RPC调用
$result = SuWS::getInstance()->rpc();

// 加入群组
$result = SuWS::getInstance()->joinGroup();

// 离开群组
$result = SuWS::getInstance()->leaveGroup();

// 解散群组
$result = SuWS::getInstance()->ungroup();

// 发送消息给群组
$result = SuWS::getInstance()->sendToGroup();

// 获取群组在线ClientId总数量
$result = SuWS::getInstance()->getClientIdCountByGroup();

// 获取群组在线客户端的会话信息
$result = SuWS::getInstance()->getClientSessionsByGroup();

// 获取群组在线ClientId列表
$result = SuWS::getInstance()->getClientIdListByGroup();

// 获取群组在线UID列表
$result = SuWS::getInstance()->getUidListByGroup();

// 获取群组在线UID总数量
$result = SuWS::getInstance()->getUidCountByGroup();

// 获取所有群组名称列表
$result = SuWS::getInstance()->getAllGroupIdList();

// 获取UID加入的群组名称列表
$result = SuWS::getInstance()->getGroupByUid();

// 重新加载配置文件
$result = SuWS::getInstance()->reloadConfig();

// 获取配置
$result = SuWS::getInstance()->getConfig();
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance70

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Total

7

Last Release

187d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4af14254189bc74029cc40f4206f8006872b0cd092c680201f204a85a490f143?d=identicon)[ledccn](/maintainers/ledccn)

---

Top Contributors

[![ledccn](https://avatars.githubusercontent.com/u/53997080?v=4)](https://github.com/ledccn "ledccn (15 commits)")

---

Tags

gogolangwebsocket

### Embed Badge

![Health badge](/badges/ledc-websocket/health.svg)

```
[![Health](https://phpackages.com/badges/ledc-websocket/health.svg)](https://phpackages.com/packages/ledc-websocket)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
