WebSocketsã§ã®éä¿¡å¦çã«é¢ããæ³¨æç¹ï¼CLOSINGã¹ãã¼ãã¨closeã¤ãã³ãã«é¢ããçåï¼
WebSocketsã®æ¥ç¶ç¶æ ã«ã¯ãCONNECTING / OPEN / CLOSING / CLOSEDã®ã¹ãã¼ããå®ãããã¦ããã
䏿¹ãCLOSINGç¶æ ã¸ã®é·ç§»ã«å¯¾å¿ããã¤ãã³ãã¯åå¨ãããCLOSEç¶æ ã¸é·ç§»ããéã«closeã¤ãã³ããçºçããã¨ããã¦ããã
ã¤ã¾ãããcloseã¤ãã³ããæ¥ãã¾ã§ã¯éä¿¡ã§ãããã¼ãã£ã¦ãªã³ã¼ããæ¸ãã¦ãã¨ãæ£å¸¸ç³»ãªã®ã«send()ã§ä¾å¤çºçããå¯è½æ§ãããã
ãªã®ã§ãé¢åã ãã©ã
if (ws.readyState == 1) { ws.send(...); }
ã®ãããªã¬ã¼ããå ¥ããå¿ è¦ããã*1ããããã¯ãws.readyState == CLOSING ç¶æ ã«ãªã£ããcloseã¤ãã³ãã®ãã³ãã©ãå¼ã³åºããããªã©ããã¼ãæ¸ãå¿ è¦ãããã
ã¨ã以ä¸ã®çµè«ã«è³ã£ããã§ããããã£ã¦ã¾ãã§ããããï¼ãï¼èè
以ä¸ãè¦æ ¼ããã®å¼ç¨ã
CONNECTING (numeric value 0)
ããThe connection has not yet been established.
OPEN (numeric value 1)
ããThe WebSocket connection is established and communication is possible.
CLOSING (numeric value 2)
ããThe connection is going through the closing handshake, or the close() method has been invoked.
CLOSED (numeric value 3)
ããThe connection has been closed or could not be opened.
When the WebSocket closing handshake is started, the user agent must queue a task to change the readyState attribute's value to CLOSING (2). (If the close() method was called, the readyState attribute's value will already be set to CLOSING (2) when this task runs.)
When the WebSocket connection is closed, possibly cleanly, the user agent must queue a task to run the following substeps:
ãã1. Change the readyState attribute's value to CLOSED (3).
ãã(ç¥)
ãã3. Create an event that uses the CloseEvent interface, with the event type close, ...
*1:å ¨äºéãªãããã³ã«ãªã®ã§ãelseç¯ã¯ä¸è¦ã§åé¡ãªãã¯ã