fix(api): use server.listen instead of app.listen for WebSocket support
- server.ts: switch from app.listen() to server.listen() so WebSocket upgrade handler is on the same server as HTTP requests - lobbyService: add host as first player on lobby creation - ws-client: guard against reconnect when already connecting - ws-provider: skip connect if already connected
This commit is contained in:
parent
974646ebfb
commit
540155788a
4 changed files with 14 additions and 2 deletions
|
|
@ -9,6 +9,8 @@ export const WsProvider = ({ children }: { children: ReactNode }) => {
|
|||
const [isConnected, setIsConnected] = useState(false);
|
||||
|
||||
const connect = useCallback(async (url: string): Promise<void> => {
|
||||
if (wsClient.isConnected()) return;
|
||||
|
||||
wsClient.onClose = () => setIsConnected(false);
|
||||
wsClient.onError = () => setIsConnected(false);
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue