You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
343 B
Go
24 lines
343 B
Go
4 years ago
|
package whappdc
|
||
4 years ago
|
|
||
|
import "log"
|
||
|
|
||
|
type ChatWorker struct {
|
||
|
incomingHandlers chan MessageHandler
|
||
|
}
|
||
|
|
||
|
func (w *ChatWorker) Start() {
|
||
|
go func() {
|
||
|
for {
|
||
|
select {
|
||
|
case handler := <-w.incomingHandlers:
|
||
|
log.Println("Chat worker executing action")
|
||
|
err := handler.Action()
|
||
|
|
||
|
if err != nil {
|
||
|
log.Println(err)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}()
|
||
|
}
|