From 706c90baa3f1fb8663262fbbd4aa16ab87ae1be8 Mon Sep 17 00:00:00 2001 From: Andrew Brampton Date: Sun, 30 Nov 2014 15:42:08 -0800 Subject: [PATCH 1/2] Ensure the time field is populated on the pseudo line events, such as connecting and disconnecting. --- client/connection.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/connection.go b/client/connection.go index 9aaf098..d5d0862 100644 --- a/client/connection.go +++ b/client/connection.go @@ -246,7 +246,7 @@ func (conn *Conn) Connect() error { } conn.connected = true conn.postConnect(true) - conn.dispatch(&Line{Cmd: REGISTER}) + conn.dispatch(&Line{Cmd: REGISTER, Time: time.Now()}) return nil } @@ -400,7 +400,7 @@ func (conn *Conn) shutdown() { conn.wg.Wait() // reinit datastructures ready for next connection conn.initialise() - conn.dispatch(&Line{Cmd: DISCONNECTED}) + conn.dispatch(&Line{Cmd: DISCONNECTED, Time: time.Now()}) } // Dumps a load of information about the current state of the connection to a From d7116e2bd0ada843b1b891438d182e98660ec437 Mon Sep 17 00:00:00 2001 From: Andrew Brampton Date: Sun, 30 Nov 2014 15:58:57 -0800 Subject: [PATCH 2/2] Also add time to the Connected event. --- client/handlers.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/handlers.go b/client/handlers.go index af6a6e2..13d1e2d 100644 --- a/client/handlers.go +++ b/client/handlers.go @@ -5,6 +5,7 @@ package client import ( "strings" + "time" ) // sets up the internal event handlers to do essential IRC protocol things @@ -42,7 +43,7 @@ func (conn *Conn) h_REGISTER(line *Line) { // Handler to trigger a CONNECTED event on receipt of numeric 001 func (conn *Conn) h_001(line *Line) { // we're connected! - conn.dispatch(&Line{Cmd: CONNECTED}) + conn.dispatch(&Line{Cmd: CONNECTED, Time: time.Now()}) // and we're being given our hostname (from the server's perspective) t := line.Args[len(line.Args)-1] if idx := strings.LastIndex(t, " "); idx != -1 {