Properly close ui websocket connections on browser close

This commit is contained in:
Jannis Mattheis 2019-11-28 21:04:03 +01:00
parent 670594c0cb
commit c9c6246c4c
2 changed files with 5 additions and 1 deletions

View File

@ -75,6 +75,10 @@ const initStores = (): StoreMapping => {
stores.currentUser.tryAuthenticate().catch(() => {});
window.onbeforeunload = () => {
stores.wsStore.close();
};
ReactDOM.render(
<InjectProvider stores={stores}>
<Layout />

View File

@ -50,5 +50,5 @@ export class WebSocketStore {
this.ws = ws;
};
public close = () => this.ws && this.ws.close();
public close = () => this.ws && this.ws.close(1000, 'WebSocketStore#close');
}