presence

command
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

Overview

presence 示例:在线状态追踪 + 频道成员列表。

演示 pkg/presence 的双索引:Track 登记在场、ListByStream 查成员、 事件总线回调 join/leave。HTTP 端点查询某频道的在线成员。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL