正确关闭WebSocket(HTML5,Javascript)
有一个奇怪的行为,当用户只是刷新页面而不调用websocket.close()–当他们返回后刷新它会打击websocket.onclose事件。解决方法根据protocolspecv76:Toclosetheconnectioncleanly,aframeconsistingofjusta0xFFbytefollowedbya0x00byteissentfromonepeertoaskthattheotherpeerclosetheconnection.如果您正在编写服务器,则应确保在服务器关闭客户端连接