|
@ -115,6 +115,16 @@ func (t *Node) RegisterClient(c *Client) error { |
|
|
if room, ok := t.rooms[c.RoomId]; ok { |
|
|
if room, ok := t.rooms[c.RoomId]; ok { |
|
|
room.rwmux.Lock() |
|
|
room.rwmux.Lock() |
|
|
defer room.rwmux.Unlock() |
|
|
defer room.rwmux.Unlock() |
|
|
|
|
|
if oc, exist := room.clients[c.Id]; exist { |
|
|
|
|
|
oc.WriteJson(&Message{ |
|
|
|
|
|
Type: "close", |
|
|
|
|
|
Data: map[string]interface{}{ |
|
|
|
|
|
"error_code": 302, |
|
|
|
|
|
"error_msg": "链接已被替换", |
|
|
|
|
|
}, |
|
|
|
|
|
}) |
|
|
|
|
|
oc.Close() |
|
|
|
|
|
} |
|
|
room.clients[c.Id] = c |
|
|
room.clients[c.Id] = c |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|