Browse Source

fix websocket crash

pull/44/head
rui.zheng 11 years ago
parent
commit
59e7057fe9
  1. 9
      ws.go

9
ws.go

@ -129,15 +129,18 @@ func (s *ws) handle(w http.ResponseWriter, r *http.Request) {
} }
func (s *ws) ListenAndServe() error { func (s *ws) ListenAndServe() error {
http.HandleFunc("/ws", s.handle) sm := http.NewServeMux()
return http.ListenAndServe(s.arg.Addr, nil) sm.HandleFunc("/ws", s.handle)
return http.ListenAndServe(s.arg.Addr, sm)
} }
func (s *ws) listenAndServeTLS() error { func (s *ws) listenAndServeTLS() error {
http.HandleFunc("/ws", s.handle) sm := http.NewServeMux()
sm.HandleFunc("/ws", s.handle)
server := &http.Server{ server := &http.Server{
Addr: s.arg.Addr, Addr: s.arg.Addr,
TLSConfig: &tls.Config{Certificates: []tls.Certificate{s.arg.Cert}}, TLSConfig: &tls.Config{Certificates: []tls.Certificate{s.arg.Cert}},
Handler: sm,
} }
return server.ListenAndServeTLS("", "") return server.ListenAndServeTLS("", "")
} }

Loading…
Cancel
Save