简体   繁体   中英

How to check if websocket connection is in readystate using “github.com/gorilla/websocket”

I'm using the "github.com/gorilla/websocket" package in Golang and I want to know if my websocket connection is in OPEN state or in CONNECTING state.

The states that I want to know can be seen here

The Gorilla package does not have the concept of these states, but here's a rough mapping from the browser states to Gorilla.

  • The Dialer.Dial and Upgrader.Upgrade methods return a connection in the OPEN state.
  • The connection is in the CLOSING state when read on the connection returns an error or the application sends a close message .
  • The connection is in the CLOSED state after the application calls Close() on the connection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM