commit
a767654908
16
irc.go
16
irc.go
@ -67,7 +67,7 @@ func (irc *Connection) readLoop() {
|
||||
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
break
|
||||
return
|
||||
}
|
||||
|
||||
if irc.Debug {
|
||||
@ -129,8 +129,7 @@ func (irc *Connection) writeLoop() {
|
||||
select {
|
||||
case <-irc.end:
|
||||
return
|
||||
default:
|
||||
b, ok := <-irc.pwrite
|
||||
case b, ok := <-irc.pwrite:
|
||||
if !ok || b == "" || irc.socket == nil {
|
||||
return
|
||||
}
|
||||
@ -189,17 +188,15 @@ func (irc *Connection) pingLoop() {
|
||||
// Main loop to control the connection.
|
||||
func (irc *Connection) Loop() {
|
||||
errChan := irc.ErrorChan()
|
||||
for !irc.stopped {
|
||||
for !irc.quit {
|
||||
err := <-errChan
|
||||
if irc.stopped {
|
||||
break
|
||||
}
|
||||
irc.Log.Printf("Error, disconnected: %s\n", err)
|
||||
for !irc.stopped {
|
||||
for !irc.quit {
|
||||
if err = irc.Reconnect(); err != nil {
|
||||
irc.Log.Printf("Error while reconnecting: %s\n", err)
|
||||
time.Sleep(1 * time.Second)
|
||||
time.Sleep(60 * time.Second)
|
||||
} else {
|
||||
errChan = irc.ErrorChan()
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -217,6 +214,7 @@ func (irc *Connection) Quit() {
|
||||
|
||||
irc.SendRaw(quit)
|
||||
irc.stopped = true
|
||||
irc.quit = true
|
||||
}
|
||||
|
||||
// Use the connection to join a given channel.
|
||||
|
@ -42,6 +42,7 @@ type Connection struct {
|
||||
Log *log.Logger
|
||||
|
||||
stopped bool
|
||||
quit bool
|
||||
}
|
||||
|
||||
// A struct to represent an event.
|
||||
|
Loading…
Reference in New Issue
Block a user