typescript on both client and server with communication via socket.io

This commit is contained in:
Gavin McDonald
2025-04-09 11:28:35 -04:00
parent 9f2773f45d
commit 3c4b8cf56e
73 changed files with 1233 additions and 41 deletions

View File

@@ -2,40 +2,12 @@
import { useEffect, useState } from "react";
import { useParams } from 'next/navigation';
import { socket } from "../../socket";
import { socket } from "@/socket";
//import Card from '@/components/Card';
import Card from '@/components/Card';
//import type { GameCard } from '@/types';
import type { GameCard } from '@/types';
export default function GamePage() {
const { gameID } = useParams();
const [cards, setCards] = useState();
useEffect(() => {
socket.emit('join', gameID);
socket.on('init', data => {
console.log('init', data);
setCards(data.id);
});
socket.on('card-flipped', (data) => {
console.log('>>>', data);
setCards(data.id);
});
return () => {
socket.off('init');
socket.off('card-flipped');
};
}, []);
return <h1>A Page! {cards}</h1>
}
/*
export default function GamePage() {
const { gameID } = useParams();
@@ -91,4 +63,3 @@ export default function GamePage() {
</main>
) : null;
}
*/