Skip to main content

monolith-websocket-pubsub

Use when implementing real-time functionality using the built-in websocket pub/sub layer (`/ws`), including subscribe/message protocol and channel design.

跳到安装

来源信息

仓库
cggonzal/monolith
最近来源活动
2026年2月14日 03:11
检测到的 SKILL.md 语言
英语
星标
0
分支
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
monolith-websocket-pubsub
description
Use when implementing real-time functionality using the built-in websocket pub/sub layer (`/ws`), including subscribe/message protocol and channel design.
# Monolith WebSocket Pub/Sub ## Use this skill when - Building chat/live updates. - Debugging channel subscriptions or message broadcast behavior. ## Entry points - Route: `GET /ws` in `app/routes/routes.go` - Implementation: `ws/ws.go` - Persistent message model: `app/models/ws.go` ## Client protocol Send JSON commands: - Subscribe: `{"command":"subscribe","identifier":"ChatChannel"}` - Publish: `{"command":"message","identifier":"ChatChannel","data":"Hello"}` ## Server behavior - Hub tracks channel subscriptions. - `message` commands are persisted then broadcast to subscribed clients. - Client loop handles register/unregister and ping/pong lifecycle. ## Extension workflow 1. Pick channel naming strategy (room, user, domain event). 2. Add frontend websocket client logic in `static/js/application.js` or app-specific JS. 3. Optionally enforce auth checks before allowing subscribe/publish. 4. Add tests in `ws/ws_test.go` style for command handling.
在 GitHub 查看