修正server端获取链接时错误的逻辑

This commit is contained in:
lwch
2021-09-01 11:33:31 +08:00
parent 2c7f67dce2
commit 8baae35014
2 changed files with 6 additions and 2 deletions
+4
View File
@@ -86,3 +86,7 @@ func (c *client) closeLink(id string) {
delete(c.links, id)
c.Unlock()
}
func (c *client) is(id string, idx uint32) bool {
return c.parent.id == id && c.idx == idx
}
+2 -2
View File
@@ -99,10 +99,10 @@ func (h *Handler) getClient(linkID, to string, toIdx uint32) *client {
pair := h.links[linkID]
h.lockLinks.RUnlock()
if pair[0] != nil && pair[0].idx == toIdx {
if pair[0] != nil && pair[0].is(to, toIdx) {
return pair[0]
}
if pair[1] != nil && pair[1].idx == toIdx {
if pair[1] != nil && pair[1].is(to, toIdx) {
return pair[1]
}