增加了发布通道
This commit is contained in:
@@ -70,6 +70,13 @@ func (c *TSClient) ConnectWithIdentity(identityStr, host, nickname, password, de
|
||||
return fmt.Sprintf("identity 解析失败: %v", err)
|
||||
}
|
||||
|
||||
// 计算 TeamSpeak UID(base64(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 ""
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user