I have trouble understanding the following excerpt of code. The run() f-n is executed as a goroutine and I think is responsible for dispatching all entries in the 'gloabl' broadcast channel to the corresponding client channels (chan.send). I lose track in the second select statement, in the case clause. Does it only push the message struct in the client.send channel or is there more to this specific syntax?
func (h *Hub) run() {
for {
select {
...
case message := <-h.broadcast:
for client := range h.clients[someid] { //clients = make(map[int][]*Client)
select {
case client.send <- message: //???
default:
close(client.send)
delete(h.clients, client)
}
}
}
}
}