fix: 按 K-00 约定修复 Go SDK 断线重交与退避

This commit is contained in:
Nixevol
2026-09-30 16:24:13 +08:00
parent 3749b9bdf1
commit f6f8ccf269
20 changed files with 1544 additions and 324 deletions
+9 -4
View File
@@ -73,6 +73,11 @@ func (c *Client) Directory(ctx context.Context, cursor, query string, limit int)
// WatchPresence 订阅上下线;ids 为空且 all 为 true 表示全部。
func (c *Client) WatchPresence(ctx context.Context, ids []string, all bool) error {
c.mu.Lock()
c.watchIDs = append([]string(nil), ids...)
c.watchAll = all
c.watchSet = true
c.mu.Unlock()
req := map[string]any{"v": 1, "type": "presence.watch", "rid": c.nextRID(), "all": all}
if len(ids) > 0 {
req["ids"] = ids
@@ -131,11 +136,11 @@ func (c *Client) ChangeLoginPassword(ctx context.Context, oldPassword, newPasswo
if c.transport != nil {
c.transport.SetCredential(d.SessionToken)
}
h := c.onSession
tok := d.SessionToken
c.mu.Unlock()
if c.onSession != nil {
c.cbMu.Lock()
c.onSession(d.SessionToken)
c.cbMu.Unlock()
if h != nil {
h(tok)
}
}
return nil