command
Version:
v0.9.2
Opens a new window with list of versions in this module.
Published: Aug 28, 2026
License: Apache-2.0
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
presence —— 在线状态
演示 pkg/transport/presence 追踪用户在线与频道成员,支持 join/leave 事件回调。
运行
go run ./examples/presence
curl "http://localhost:8283/online?user=alice&session=s1&channel=room1"
curl "http://localhost:8283/online?user=bob&session=s2&channel=room1"
curl "http://localhost:8283/members?channel=room1"
curl "http://localhost:8283/offline?session=s1&channel=room1&user=alice"
说明
Track(session, stream, meta) 登记在场;Untrack 移除;ListByStream 查频道成员列表。
- 构造函数传入回调,join/leave 时打印日志(可对接 eventbus、审计等)。
- 与
pkg/transport/router 配合可实现「发消息给某频道所有人」。
Documentation
¶
presence 示例:在线状态追踪 + 频道成员列表。
演示 pkg/presence 的双索引:Track 登记在场、ListByStream 查成员、
事件总线回调 join/leave。HTTP 端点查询某频道的在线成员。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.