Overnap
Builds for 1 pipeline passed in 8 minutes 2 seconds

라운드 끝날 때 정답 공개 추가

...@@ -24,10 +24,12 @@ export const Chat: React.FC<ChatProps> = (props) => { ...@@ -24,10 +24,12 @@ export const Chat: React.FC<ChatProps> = (props) => {
24 24
25 socket.on('msg', handleChatData); 25 socket.on('msg', handleChatData);
26 socket.on('msg', handleAcceptMessage); 26 socket.on('msg', handleAcceptMessage);
27 + socket.on('msg', handleFinishMessage);
27 28
28 return () => { 29 return () => {
29 socket.off('msg', handleChatData); 30 socket.off('msg', handleChatData);
30 socket.off('msg', handleAcceptMessage); 31 socket.off('msg', handleAcceptMessage);
32 + socket.on('msg', handleFinishMessage);
31 } 33 }
32 }, []); 34 }, []);
33 35
...@@ -59,6 +61,16 @@ export const Chat: React.FC<ChatProps> = (props) => { ...@@ -59,6 +61,16 @@ export const Chat: React.FC<ChatProps> = (props) => {
59 } 61 }
60 }, []); 62 }, []);
61 63
64 + const handleFinishMessage = useCallback((rawMessage: RawMessage) => {
65 + if (rawMessage.type === MessageType.GAME_FINISH_ROUND) {
66 + const message: ChatData = {
67 + sender: 'SYSTEM',
68 + message: 'The round is over!'
69 + };
70 + setChatLines(oldChatLines => [...oldChatLines, message]);
71 + }
72 + }, []);
73 +
62 return ( 74 return (
63 <div className={props.w}> 75 <div className={props.w}>
64 <div className={`${props.h} w-full py-2 rounded shadow flex flex-col overflow-y-scroll`}> 76 <div className={`${props.h} w-full py-2 rounded shadow flex flex-col overflow-y-scroll`}>
......
...@@ -56,7 +56,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => { ...@@ -56,7 +56,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
56 }, [wordChosen]); 56 }, [wordChosen]);
57 57
58 const handleAnswer = useCallback((rawMessage: RawMessage) => { 58 const handleAnswer = useCallback((rawMessage: RawMessage) => {
59 - if (rawMessage.type === MessageType.GAME_ACCEPT) { 59 + if (rawMessage.type === MessageType.GAME_ACCEPT || rawMessage.type === MessageType.GAME_FINISH_ROUND) {
60 const { answer } = rawMessage.message as { answer: string }; 60 const { answer } = rawMessage.message as { answer: string };
61 setWordChosen(answer); 61 setWordChosen(answer);
62 } 62 }
......