Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강동현
/
nodejs-game
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Overnap
2021-06-10 07:22:58 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4debe593fb60345e415640d5fda0e061c6e0b60a
4debe593
1 parent
d71b490f
Builds for 1 pipeline
passed
in 8 minutes 2 seconds
라운드 끝날 때 정답 공개 추가
Changes
2
Builds
3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletions
web/src/components/room/Chat.tsx
web/src/components/room/GameBoard.tsx
web/src/components/room/Chat.tsx
View file @
4debe59
...
...
@@ -24,10 +24,12 @@ export const Chat: React.FC<ChatProps> = (props) => {
socket.on('msg', handleChatData);
socket.on('msg', handleAcceptMessage);
socket.on('msg', handleFinishMessage);
return () => {
socket.off('msg', handleChatData);
socket.off('msg', handleAcceptMessage);
socket.on('msg', handleFinishMessage);
}
}, []);
...
...
@@ -59,6 +61,16 @@ export const Chat: React.FC<ChatProps> = (props) => {
}
}, []);
const handleFinishMessage = useCallback((rawMessage: RawMessage) => {
if (rawMessage.type === MessageType.GAME_FINISH_ROUND) {
const message: ChatData = {
sender: 'SYSTEM',
message: 'The round is over!'
};
setChatLines(oldChatLines => [...oldChatLines, message]);
}
}, []);
return (
<div className={props.w}>
<div className={`${props.h} w-full py-2 rounded shadow flex flex-col overflow-y-scroll`}>
...
...
web/src/components/room/GameBoard.tsx
View file @
4debe59
...
...
@@ -56,7 +56,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
}, [wordChosen]);
const handleAnswer = useCallback((rawMessage: RawMessage) => {
if (rawMessage.type === MessageType.GAME_ACCEPT) {
if (rawMessage.type === MessageType.GAME_ACCEPT
|| rawMessage.type === MessageType.GAME_FINISH_ROUND
) {
const { answer } = rawMessage.message as { answer: string };
setWordChosen(answer);
}
...
...
Please
register
or
login
to post a comment