Skip to content

Commit

Permalink
Merge pull request #14 from shibisuriya/feat/multiple-snakes
Browse files Browse the repository at this point in the history
fix: removed ws
  • Loading branch information
shibisuriya authored Sep 29, 2023
2 parents ef0bb9b + f74ed40 commit a757371
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions packages/game-client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,32 @@ import Grid from './Grid';
const SPEED = 1 * 100;

function App() {
const socket = useRef();
// const socket = useRef();
useEffect(() => {
// For now I am going to be using a simple websocket server for
// developer & testing purposes.
const { hostname, port } = window.location;
const WS_PORT = 8085;
socket.current = new WebSocket(`ws://${hostname}:${WS_PORT}`);
socket.current.addEventListener('open', (event) => {
console.log('WebSocket connection opened:', event);
});

socket.current.addEventListener('message', (event) => {
const message = event.data;
console.log('message -> ', message);
});

socket.current.addEventListener('close', (event) => {
console.log('WebSocket connection closed:', event);
});

socket.current.addEventListener('error', (event) => {
console.error('WebSocket error:', event);
});

return () => {
// Disconnect...
if (socket.current) {
socket.current.close();
}
};
// const { hostname, port } = window.location;
// const WS_PORT = 8085;
// socket.current = new WebSocket(`ws://${hostname}:${WS_PORT}`);
// socket.current.addEventListener('open', (event) => {
// console.log('WebSocket connection opened:', event);
// });
// socket.current.addEventListener('message', (event) => {
// const message = event.data;
// console.log('message -> ', message);
// });
// socket.current.addEventListener('close', (event) => {
// console.log('WebSocket connection closed:', event);
// });
// socket.current.addEventListener('error', (event) => {
// console.error('WebSocket error:', event);
// });
// return () => {
// // Disconnect...
// if (socket.current) {
// socket.current.close();
// }
// };
}, []);

const [snakeId, setSnakeId] = useState(1);
Expand Down

0 comments on commit a757371

Please sign in to comment.