mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 20:09:41 +01:00
Actually let the takeover work somewhat more properly
This commit is contained in:
parent
0d5327de8a
commit
7760634efe
@ -351,6 +351,9 @@ func (client *Client) TryResume() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unmark the new client's nick as being occupied
|
||||||
|
server.clients.removeInternal(client)
|
||||||
|
|
||||||
// send RESUMED to the reconnecting client
|
// send RESUMED to the reconnecting client
|
||||||
if timestamp == nil {
|
if timestamp == nil {
|
||||||
client.Send(nil, oldClient.NickMaskString(), "RESUMED", oldClient.nick, client.username, client.Hostname())
|
client.Send(nil, oldClient.NickMaskString(), "RESUMED", oldClient.nick, client.username, client.Hostname())
|
||||||
@ -402,7 +405,7 @@ func (client *Client) TryResume() {
|
|||||||
|
|
||||||
server.clients.byNick[oldnick] = client
|
server.clients.byNick[oldnick] = client
|
||||||
|
|
||||||
oldClient.destroy(false)
|
oldClient.destroy(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IdleTime returns how long this client's been idle.
|
// IdleTime returns how long this client's been idle.
|
||||||
@ -602,6 +605,7 @@ func (client *Client) Quit(message string) {
|
|||||||
// destroy gets rid of a client, removes them from server lists etc.
|
// destroy gets rid of a client, removes them from server lists etc.
|
||||||
func (client *Client) destroy(beingResumed bool) {
|
func (client *Client) destroy(beingResumed bool) {
|
||||||
// allow destroy() to execute at most once
|
// allow destroy() to execute at most once
|
||||||
|
if !beingResumed {
|
||||||
client.stateMutex.Lock()
|
client.stateMutex.Lock()
|
||||||
isDestroyed := client.isDestroyed
|
isDestroyed := client.isDestroyed
|
||||||
client.isDestroyed = true
|
client.isDestroyed = true
|
||||||
@ -609,6 +613,7 @@ func (client *Client) destroy(beingResumed bool) {
|
|||||||
if isDestroyed {
|
if isDestroyed {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if beingResumed {
|
if beingResumed {
|
||||||
client.server.logger.Debug("quit", fmt.Sprintf("%s is being resumed", client.nick))
|
client.server.logger.Debug("quit", fmt.Sprintf("%s is being resumed", client.nick))
|
||||||
@ -647,18 +652,26 @@ func (client *Client) destroy(beingResumed bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("2")
|
||||||
|
|
||||||
// clean up server
|
// clean up server
|
||||||
if !beingResumed {
|
if !beingResumed {
|
||||||
client.server.clients.Remove(client)
|
client.server.clients.Remove(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("3")
|
||||||
|
|
||||||
// clean up self
|
// clean up self
|
||||||
if client.idletimer != nil {
|
if client.idletimer != nil {
|
||||||
client.idletimer.Stop()
|
client.idletimer.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("4")
|
||||||
|
|
||||||
client.socket.Close()
|
client.socket.Close()
|
||||||
|
|
||||||
|
fmt.Println("5")
|
||||||
|
|
||||||
// send quit messages to friends
|
// send quit messages to friends
|
||||||
if !beingResumed {
|
if !beingResumed {
|
||||||
for friend := range friends {
|
for friend := range friends {
|
||||||
|
Loading…
Reference in New Issue
Block a user