]> 127.0.0.1 Git - part/.git/commitdiff
1 v0.28.20240310094912
authorqydysky <qydysky@foxmail.com>
Sun, 10 Mar 2024 09:43:26 +0000 (17:43 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 10 Mar 2024 09:43:26 +0000 (17:43 +0800)
websocket/Server.go

index a83833239620aa38c1bafad8c6590f8efd79c9b7..8d7b99aeeaf237d492ffe49eaf136766860873be 100644 (file)
@@ -37,15 +37,15 @@ func New_server() *Server {
 func (t *Server) WS(w http.ResponseWriter, r *http.Request) (o chan uintptr) {
        upgrader := websocket.Upgrader{}
 
+       o = make(chan uintptr, 1)
+
        ws, err := upgrader.Upgrade(w, r, nil)
        if err != nil {
-               w.WriteHeader(http.StatusBadRequest)
+               close(o)
                t.ws_mq.Push_tag(`error`, err)
                return
        }
 
-       o = make(chan uintptr, 1)
-
        //从池中获取本会话id
        User := t.userpool.Get()