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.Realname = server.Realname
go func(server storage.Server) {
i.Connect(server.Address)
session.setIRC(i.Host, i)
i.Connect(server.Address)
session.setIRC(i.Host, i)
go handleIRC(i, session)
go handleIRC(i, session)
var joining []string
for _, channel := range channels {
if channel.Server == server.Address {
joining = append(joining, channel.Name)
}
var joining []string
for _, channel := range channels {
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)
}
go func() {
i.Connect(data.Server)
go handleIRC(i, session)
i.Connect(data.Server)
go handleIRC(i, session)
session.user.AddServer(storage.Server{
Name: data.Name,
Address: i.Host,
TLS: data.TLS,
Password: data.Password,
Nick: data.Nick,
Username: data.Username,
Realname: data.Realname,
})
}()
session.user.AddServer(storage.Server{
Name: data.Name,
Address: i.Host,
TLS: data.TLS,
Password: data.Password,
Nick: data.Nick,
Username: data.Username,
Realname: data.Realname,
})
} else {
log.Println(addr, "already connected to", data.Server)
}