这是非常简单的:readyState
websocket 的属性总是包含websocket的连接,正如WebSocket API
它将是以下值之一:CONNECTING
OPEN
CLOSING
或CLOSED
解决错误的方法是这样的:
if(yourWsObject.readyState === yourWsObject.CLOSED){ // Do your stuff... }
这是非常简单的:readyState
websocket 的属性总是包含websocket的连接,正如WebSocket API
它将是以下值之一:CONNECTING
OPEN
CLOSING
或CLOSED
解决错误的方法是这样的:
if(yourWsObject.readyState === yourWsObject.CLOSED){ // Do your stuff... }