Builds for
1 pipeline
failed
in
1 minute 13 seconds
클라이언트 핑퐁 추가
Showing
1 changed file
with
6 additions
and
0 deletions
... | @@ -73,6 +73,10 @@ const Room: React.FC = () => { | ... | @@ -73,6 +73,10 @@ const Room: React.FC = () => { |
73 | } | 73 | } |
74 | }, [roomData]); | 74 | }, [roomData]); |
75 | 75 | ||
76 | + const handlePing = useCallback(() => { | ||
77 | + socket.emit('ping', {}, () => {}); | ||
78 | + }, []); | ||
79 | + | ||
76 | useEffect(() => { | 80 | useEffect(() => { |
77 | socket.on('msg', handleUpdateRoomUser); | 81 | socket.on('msg', handleUpdateRoomUser); |
78 | 82 | ||
... | @@ -90,9 +94,11 @@ const Room: React.FC = () => { | ... | @@ -90,9 +94,11 @@ const Room: React.FC = () => { |
90 | 94 | ||
91 | setRoomData(location.state.roomData); | 95 | setRoomData(location.state.roomData); |
92 | socket.on('msg', handleInGame); | 96 | socket.on('msg', handleInGame); |
97 | + socket.on('ping', handlePing); | ||
93 | 98 | ||
94 | return () => { | 99 | return () => { |
95 | socket.off('msg', handleInGame); | 100 | socket.off('msg', handleInGame); |
101 | + socket.off('ping', handlePing); | ||
96 | 102 | ||
97 | const rawMessage: RawMessage = { | 103 | const rawMessage: RawMessage = { |
98 | type: MessageType.ROOM_LEAVE, | 104 | type: MessageType.ROOM_LEAVE, | ... | ... |
-
Please register or login to post a comment