automatic rejoin on reload or server restart
This commit is contained in:
parent
feaf96c10e
commit
64a61ef2b3
11 changed files with 141 additions and 58 deletions
|
|
@ -3,8 +3,9 @@ import useWebSocket from 'react-use-websocket';
|
|||
import {useEffect} from 'react';
|
||||
import {statusTextForReadyState} from './statusTextForReadyState.tsx';
|
||||
|
||||
export default function Controls({playerId}: {
|
||||
playerId: string
|
||||
export default function Controls({playerId, logout}: {
|
||||
playerId: string,
|
||||
logout: () => void
|
||||
}) {
|
||||
const url = new URL(import.meta.env.VITE_TANK_CONTROLS_URL);
|
||||
url.searchParams.set('playerId', playerId);
|
||||
|
|
@ -13,7 +14,7 @@ export default function Controls({playerId}: {
|
|||
getWebSocket,
|
||||
readyState
|
||||
} = useWebSocket(url.toString(), {
|
||||
shouldReconnect: () => true,
|
||||
onError: logout
|
||||
});
|
||||
|
||||
const socket = getWebSocket();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue