diff --git a/server-ctl.go b/server-ctl.go index 0264c70..30a1649 100644 --- a/server-ctl.go +++ b/server-ctl.go @@ -23,6 +23,10 @@ type server_ctl_server_conns struct { s *Server } +type server_ctl_server_conns_id struct { + s *Server +} + // ------------------------------------ func (ctl *server_ctl_server_conns) ServeHTTP(w http.ResponseWriter, req *http.Request) { @@ -63,7 +67,7 @@ func (ctl *server_ctl_server_conns) ServeHTTP(w http.ResponseWriter, req *http.R if err = je.Encode(js); err != nil { goto oops } case http.MethodDelete: -// TODO s.ReqStopAllServerConns() + s.ReqStopAllServerConns() status_code = http.StatusNoContent; w.WriteHeader(status_code) default: @@ -78,3 +82,9 @@ oops: s.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error()) return } + +// ------------------------------------ + +func (ctl *server_ctl_server_conns_id) ServeHTTP(w http.ResponseWriter, req *http.Request) { + // TODO: +} diff --git a/server.go b/server.go index 802e18b..77b36a0 100644 --- a/server.go +++ b/server.go @@ -895,6 +895,17 @@ func (s *Server) AddNewServerConn(remote_addr *net.Addr, local_addr *net.Addr, p return &cts, nil } +func (s *Server) ReqStopAllServerConns() { + var cts *ServerConn + + s.cts_mtx.Lock() + defer s.cts_mtx.Unlock() + + for _, cts = range s.cts_map { + cts.ReqStop() + } +} + func (s *Server) RemoveServerConn(cts *ServerConn) { s.cts_mtx.Lock() delete(s.cts_map, cts.caddr)