This commit is contained in:
Zack Guo
2017-05-02 22:11:46 +08:00
parent 86c275c69b
commit 1fd509e58d
2 changed files with 25 additions and 24 deletions

View File

@@ -68,7 +68,7 @@ func (s *Server) ListenAndServe() error {
http.Handle(s.Path, websocket.Handler(func(ws *websocket.Conn) {
defer ws.Close()
mc := make(chan string)
mc := make(chan string, 10)
s.chs = append(s.chs, mc)
for m := range mc {
@@ -79,7 +79,7 @@ func (s *Server) ListenAndServe() error {
go func() {
for msg := range s.Msg {
for _, c := range s.chs {
go func(a chan string) {
func(a chan string) {
a <- msg
}(c)
}