unconditionally wait 30 seconds before reconnecting

This commit is contained in:
raylu 2011-07-21 23:15:52 -07:00
parent d961c92dd1
commit d139fab231
1 changed files with 1 additions and 5 deletions

View File

@ -71,19 +71,15 @@ func connect(network string) {
c.AddHandler("join", handleJoin) c.AddHandler("join", handleJoin)
c.AddHandler("invite", handleInvite) c.AddHandler("invite", handleInvite)
var lastAttempt int64 = 0
for { for {
lastAttempt = time.Seconds()
fmt.Printf("Connecting to %s...\n", server) fmt.Printf("Connecting to %s...\n", server)
if err := c.Connect(server); err != nil { if err := c.Connect(server); err != nil {
fmt.Printf("Connection error: %s\n", err) fmt.Printf("Connection error: %s\n", err)
if time.Seconds() - lastAttempt < 30 {
time.Sleep(60000000000) // 1 minute
}
} }
for err := range c.Err { for err := range c.Err {
fmt.Printf("goirc error: %s\n", err) fmt.Printf("goirc error: %s\n", err)
} }
time.Sleep(30000000000) // 30 seconds
} }
} }