Added socket disconnect on game unmount

This commit is contained in:
Mitchell McCaffrey 2021-02-20 16:23:37 +11:00
parent 77bb13e8e6
commit c55e236a61
2 changed files with 8 additions and 0 deletions

View File

@ -105,6 +105,10 @@ class Session extends EventEmitter {
}
}
disconnect() {
this.socket.disconnect();
}
/**
* Send data to a single peer
*

View File

@ -33,6 +33,10 @@ function Game() {
await session.connect();
}
connect();
return () => {
session.disconnect();
};
}, [session]);
// Handle session errors