socket: Move to a timing-out send method that reduces goroutines and ensures QUIT/ERROR are sent

This commit is contained in:
Daniel Oaks
2017-04-18 20:29:00 +10:00
parent 067f982da4
commit f7a4f5d956
2 changed files with 35 additions and 22 deletions
+7 -3
View File
@@ -436,9 +436,13 @@ func (client *Client) ChangeNickname(nickname string) error {
// Quit sends the given quit message to the client (but does not destroy them).
func (client *Client) Quit(message string) {
if !client.quitMessageSent {
client.Send(nil, client.nickMaskString, "QUIT", message)
client.Send(nil, "", "ERROR", message)
client.socket.Write("\r\n")
quitMsg := ircmsg.MakeMessage(nil, client.nickMaskString, "QUIT", message)
quitLine, _ := quitMsg.Line()
errorMsg := ircmsg.MakeMessage(nil, "", "ERROR", message)
errorLine, _ := errorMsg.Line()
client.socket.FinalData = quitLine + errorLine
client.quitMessageSent = true
}
}