Stop creating new goroutines for irc.Connect() since it doesnt block anymore

This commit is contained in:
Ken-Håvard Lieng 2015-06-06 01:02:02 +02:00
parent adcf12e1fa
commit ebdb382706
2 changed files with 20 additions and 25 deletions

View File

@ -69,20 +69,17 @@ func reconnect() {
i.Password = server.Password i.Password = server.Password
i.Realname = server.Realname i.Realname = server.Realname
go func(server storage.Server) { i.Connect(server.Address)
i.Connect(server.Address) session.setIRC(i.Host, i)
session.setIRC(i.Host, i) go handleIRC(i, session)
go handleIRC(i, session) var joining []string
for _, channel := range channels {
var joining []string if channel.Server == server.Address {
for _, channel := range channels { joining = append(joining, channel.Name)
if channel.Server == server.Address {
joining = append(joining, channel.Name)
}
} }
i.Join(joining...) }
}(server) i.Join(joining...)
} }
} }
} }

View File

@ -99,20 +99,18 @@ func handleWS(conn *websocket.Conn) {
session.setIRC(data.Server[:idx], i) session.setIRC(data.Server[:idx], i)
} }
go func() { i.Connect(data.Server)
i.Connect(data.Server) go handleIRC(i, session)
go handleIRC(i, session)
session.user.AddServer(storage.Server{ session.user.AddServer(storage.Server{
Name: data.Name, Name: data.Name,
Address: i.Host, Address: i.Host,
TLS: data.TLS, TLS: data.TLS,
Password: data.Password, Password: data.Password,
Nick: data.Nick, Nick: data.Nick,
Username: data.Username, Username: data.Username,
Realname: data.Realname, Realname: data.Realname,
}) })
}()
} else { } else {
log.Println(addr, "already connected to", data.Server) log.Println(addr, "already connected to", data.Server)
} }