增加了发布通道

This commit is contained in:
sansen
2026-07-23 19:37:20 +08:00
parent e3d03d74ea
commit e8a45032f8
35 changed files with 1489 additions and 413 deletions
+16 -1
View File
@@ -70,6 +70,13 @@ func (c *TSClient) ConnectWithIdentity(identityStr, host, nickname, password, de
return fmt.Sprintf("identity 解析失败: %v", err)
}
// 计算 TeamSpeak UIDbase64(SHA1(publicKey))),用于僵尸会话过滤。
// 不能直接存储 identity 字符串,因为 UID 是公钥的哈希,格式完全不同。
uid := crypto.GetUidFromPublicKey(identity.PublicKeyBase64())
c.mu.Lock()
c.selfUID = uid
c.mu.Unlock()
opts := []ts.ClientOption{}
if password != "" {
opts = append(opts, ts.WithServerPassword(password))
@@ -102,7 +109,15 @@ func (c *TSClient) ConnectWithIdentity(identityStr, host, nickname, password, de
return fmt.Sprintf("连接失败: %v", err)
}
c.cleanupDuplicateIdentitySessions(client, identity)
// 延迟执行僵尸清理:连接刚建立时客户端在默认频道,ListClients 可能尚未
// 收到服务器发来的完整客户端列表。延迟 3 秒确保所有 notifycliententerview
// 事件已到达,此时 ListClients 能发现不同频道中的僵尸会话。
go func() {
time.Sleep(3 * time.Second)
if c.isCurrentClient(client) {
c.cleanupDuplicateIdentitySessions(client, identity)
}
}()
return ""
}