Attempt to gracefully close the socket
This commit is contained in:
		
							parent
							
								
									d63d7e7ffc
								
							
						
					
					
						commit
						b67e87d19e
					
				|  | @ -18,6 +18,15 @@ const mouseEvents = { | ||||||
|     wheel: true, |     wheel: true, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | window.onbeforeunload = function() { | ||||||
|  |     if (socket != null) { | ||||||
|  |         socket.close (1001, "Unloading page"); | ||||||
|  |         socket = null; | ||||||
|  |         console.log ("Web socket closed"); | ||||||
|  |     } | ||||||
|  |     return null; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| function ooui (rootElementPath) { | function ooui (rootElementPath) { | ||||||
|     var opened = false; |     var opened = false; | ||||||
| 
 | 
 | ||||||
|  | @ -135,6 +144,7 @@ function msgListen (m) { | ||||||
|             }; |             }; | ||||||
|         } |         } | ||||||
|         const ems = JSON.stringify (em); |         const ems = JSON.stringify (em); | ||||||
|  |         if (socket != null) | ||||||
|             socket.send (ems); |             socket.send (ems); | ||||||
|         if (debug) console.log ("Event", em); |         if (debug) console.log ("Event", em); | ||||||
|         if (em.k === "submit") |         if (em.k === "submit") | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue