diff --git a/irc.go b/irc.go index 2cc039e..0af7186 100644 --- a/irc.go +++ b/irc.go @@ -102,16 +102,13 @@ func (irc *Connection) readLoop() { // Loop to write to a connection. To be used as a goroutine. func (irc *Connection) writeLoop() { - irc.Log.Printf("writeLoop() created") defer irc.Done() for { select { case <-irc.end: - irc.Log.Printf("got irc.end, returning") return default: b, ok := <-irc.pwrite - irc.Log.Printf("got pwrite in writeLoop()") if !ok || b == "" || irc.socket == nil { return } @@ -177,11 +174,9 @@ func (irc *Connection) Loop() { irc.Log.Printf("Error, disconnected: %s\n", err) //irc.Disconnect() for !irc.stopped { - irc.Log.Printf("Reconnecting in 3 seconds") - time.Sleep(3 * time.Second) if err = irc.Reconnect(); err != nil { irc.Log.Printf("Error while reconnecting: %s\n", err) - //time.Sleep(1 * time.Second) + time.Sleep(1 * time.Second) } else { break } @@ -285,7 +280,6 @@ func (irc *Connection) Mode(target string, modestring ...string) { // A disconnect sends all buffered messages (if possible), // stops all goroutines and then closes the socket. func (irc *Connection) Disconnect() { - fmt.Println("closing channels") close(irc.end) close(irc.pwrite) close(irc.pread) @@ -360,17 +354,14 @@ func (irc *Connection) Connect(server string) error { irc.pread = make(chan string, 10) irc.pwrite = make(chan string, 10) irc.Error = make(chan error, 2) - irc.Log.Printf("Created channels") irc.Add(3) go irc.readLoop() go irc.writeLoop() go irc.pingLoop() - irc.Log.Printf("created go routines") if len(irc.Password) > 0 { irc.pwrite <- fmt.Sprintf("PASS %s\r\n", irc.Password) } irc.pwrite <- fmt.Sprintf("NICK %s\r\n", irc.nick) - irc.Log.Printf("sent NICK") irc.pwrite <- fmt.Sprintf("USER %s 0.0.0.0 0.0.0.0 :%s\r\n", irc.user, irc.user) return nil }