webSocket的readyState屬性用來定義連接狀態,該屬性的值有下面幾種:
0 :對應常量CONNECTING (numeric value 0),
正在建立連接連接,還沒有完成。The connection has not yet been established.
1 :對應常量OPEN (numeric value 1),
連接成功建立,可以進行通信。The WebSocket connection is established and communication is possible.
2 :對應常量CLOSING (numeric value 2)
連接正在進行關閉握手,即將關閉。The connection is going through the closing handshake.
3 : 對應常量CLOSED (numeric value 3)
連接已經關閉或者根本沒有建立。The connection has been closed or could not be opened.