Repository navigation
feat(webapp): WebSocket 房间与广播(#68) - #79
Merged
Merged
Conversation
Antruly
force-pushed
the
feat/ws-rooms
branch
from
November 21, 2026 15:00
b291927 to
ef82f7b
Compare
新增 `uvcpp_ws_rooms`: - `join/leave/leave_all`、`room_size/room_count/member_count`; - `broadcast_text/binary`、`broadcast_all_text`,返回成功投递数并可取 dropped; - **成员资格随会话终结自动摘除**:`uvcpp_ws_connection` 新增可叠加的 `add_close_observer()`(与单槽 `on_close` 不同,任何一条终结路径恰触发一次), 房间表在首次 join 时挂一个,断线/协议错误/主动 close/服务器停机都清干净; - **慢客户端策略**:单条连接发送积压 > `max_queue_bytes`(默认 1 MiB)时按 `DROP`(跳过这一条,默认)或 `CLOSE`(1001)处置,`stats()` 记 delivered/dropped/closed_slow;一条不读数据的连接拖不慢整场广播; - 顺手给 `uvcpp_ws_connection` 加 `pending_send_bytes()`(积压判定需要它)。 用例 `web_app_ws_rooms_func`:裸 TCP 做 WS 握手/帧解析,验证按房间隔离 (roomA 两人收到、roomB 收不到)、断线自动退订、DROP 只丢第二条且连接不断、 CLOSE 关连接且 closed_slow=1、stats 与房间/成员计数一致。 文档 `doc/webapp-guide.md` §21;ws_connection 插行引起的文档行号引用已人工核对 (multiloop-design 的 notify_retired 区间、web-ws-guide 的 39 处)并刷新锁。 本地 build-all 163/163、build-h3/default 编过;五条文档门禁全绿。
Antruly
force-pushed
the
feat/ws-rooms
branch
from
November 21, 2026 17:30
7da1cd5 to
dbe0344
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #68.
内容
新增
uvcpp_ws_rooms(src/webapp/uvcpp_ws_rooms.h):join/leave/leave_all、room_size/room_count/member_count;broadcast_text/binary、broadcast_all_text,返回成功投递数,另有出参dropped;uvcpp_ws_connection新增可叠加的add_close_observer()(与单槽on_close不同:对端 Close、异常断开、本端close()、协议错误、服务器停机任何一条终结路径都恰好触发一次)。房间表在首次join()时挂一个,断线后房间/成员计数立刻回落,业务不用再手写 on_close 清理;pending_send_bytes())超过max_queue_bytes(默认 1 MiB)时:DROP(默认):跳过这一条,其他成员照常收;CLOSE:1001 关掉这条连接。stats()记delivered / dropped / closed_slow / rooms / members;一条不读数据的连接拖不慢整场广播;app.post()投回来。用例
web_app_ws_rooms_func.cpp,WS 客户端用裸 TCP 做握手与帧解析(需要区分"收到/没收到"):stats.dropped涨;stats.closed_slow=1。验证
check_docs/check_doc_lines/check_doc_versions/check_ci_layout全绿(ws_connection 插行引起的 39 处文档行号引用已逐条人工核对并刷新锁)。(分支基于
master;runner 漂移那几条红会由 #77 合入后 rebase 掉。)