Stop message handler goroutine when connection closes

This commit is contained in:
Ken-Håvard Lieng 2015-05-16 03:56:58 +02:00
parent e55760a1a5
commit f497e248f1
2 changed files with 13 additions and 6 deletions

View file

@ -12,7 +12,12 @@ func handleMessages(irc *IRC, session *Session) {
userBuffers := make(map[string][]string)
var motd MOTD
for msg := range irc.Messages {
for {
msg, ok := <-irc.Messages
if !ok {
return
}
switch msg.Command {
case NICK:
session.sendJSON("nick", Nick{