Skip to content

Commit

Permalink
refactor: remove socket logic from component
Browse files Browse the repository at this point in the history
  • Loading branch information
punchanabu committed Mar 30, 2024
1 parent 6e08a8a commit 5daa3e6
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions apps/web/src/app/(screen)/screen/components/Display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,78 +16,6 @@ const Display= () => {
const [cu, setCu] = useState(48);



/* useEffect(() => {
const handleConnect = () => {
console.log('Client has connected to the server!');
};
const handleScoreBoard = (scoreString: string) => {
console.log(scoreString);
// TODO : handle scoreboard
// NOTE: expect the the score to be percentage
}
const handleCid = (serverCid: string) => {
try {
console.log('Received cid from server:', serverCid);
cookies.set('cid', serverCid);
console.log('cid cookie set with value:', serverCid);
} catch (error) {
console.error('Error handling cid:', error);
}
};
const handleEvents = (events: string) => {
console.log(events)
setIsStart(events != "stop")
setCu(1);
setTu(1);
if(setState != undefined){
if(events == "stop"){
tu > cu ? setState('tu') : setState('cu')
}
else{
setState('none')
}
}
}
const handleDisconnect = () => {
console.log('The client has disconnected!');
};
(async () => {
const fp = await FingerprintJS.load();
const result = await fp.get();
const fid = result.visitorId;
const savedCid = cookies.get('cid');
const extraHeaders: { [key: string]: string } = {
fid: fid,
name: 'pun1'
};
if (savedCid) {
extraHeaders.cid = savedCid;
}
const socket = io('wss://api.cutu2024.sgcu.in.th', {
auth: extraHeaders,
path: "/api/ws",
transports: ['websocket'],
});
socket.on('connect', handleConnect);
socket.on('cid', handleCid);
socket.on('scoreboard', handleScoreBoard)
socket.on('disconnect', handleDisconnect);
socket.on('events', handleEvents);
return () => {
socket?.disconnect();
};
})();
}, []); */

return (
<div className='w-auto h-screen flex'>
{state == 'none' &&
Expand Down

0 comments on commit 5daa3e6

Please sign in to comment.