From 34a099b61a7f1196f941d6991c850aef82395285 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Wed, 22 Jun 2016 22:04:13 +1000 Subject: [PATCH] Fix PING and PONG --- irc/client.go | 4 +++- irc/server.go | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/irc/client.go b/irc/client.go index e2bbc4a6..bc4543f2 100644 --- a/irc/client.go +++ b/irc/client.go @@ -27,6 +27,7 @@ type Client struct { channels ChannelSet ctime time.Time flags map[UserMode]bool + isQuitting bool hasQuit bool hops uint hostname Name @@ -99,7 +100,7 @@ func (client *Client) run() { } isExiting = cmd.Run(client.server, client, msg) - if isExiting { + if isExiting || client.isQuitting { break } } @@ -114,6 +115,7 @@ func (client *Client) run() { func (client *Client) connectionTimeout() { client.Quit("connection timeout") + client.isQuitting = true } // diff --git a/irc/server.go b/irc/server.go index 44cf94bd..831cc6fb 100644 --- a/irc/server.go +++ b/irc/server.go @@ -419,15 +419,14 @@ func quitHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { // PING [] func pingHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { - // client.Socket.Send(response here) - return true + client.Send(nil, server.nameString, "PONG", msg.Params...) + return false } // PONG [ ] func pongHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { - //TODO(dan): update client idle timer from this - //TODO(dan): use this to affect how often we send pings - return true + // client gets touched when they send this command, so we don't need to do anything + return false } // JOIN {,} [{,}]