Skip to content

Commit

Permalink
refactor: 🔥 updateGameRoom, gamePing 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
devleomk1 committed Feb 18, 2023
1 parent eb42d48 commit 9d7dabe
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 42 deletions.
31 changes: 0 additions & 31 deletions frontend/src/hooks/useHandleSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import {
joinChatRoomState,
leaveChatRoomState,
newChatRoomState,
newGamePingMessageState,
newMessageState,
updateChatRoomState,
joinGameRoomState,
newGameRoomState,
updateGameRoomState,
leaveGameRoomState,
} from 'store';
import { useSetSocketHandler } from './useSetSocketHandler';
Expand Down Expand Up @@ -56,18 +54,13 @@ export function useHandleSocket() {
const updateChatRoom = useRecoilValue(updateChatRoomState);
const resetUpdateChatRoom = useResetRecoilState(updateChatRoomState);

/* Pong Test */
const [newGamePingMessage, setNewGamePingMessage] = useRecoilState(newGamePingMessageState);

/* Game Room */
const newGameRoom = useRecoilValue(newGameRoomState);
const resetNewGameRoom = useResetRecoilState(newGameRoomState);
const joinGameRoom = useRecoilValue(joinGameRoomState);
const resetJoinGameRoom = useResetRecoilState(joinGameRoomState);
const leaveGameRoom = useRecoilValue(leaveGameRoomState);
const resetLeaveGameRoom = useResetRecoilState(leaveGameRoomState);
const updateGameRoom = useRecoilValue(updateGameRoomState);
const resetUpdateGameRoom = useResetRecoilState(updateGameRoomState);

const {
connectHandler,
Expand All @@ -77,8 +70,6 @@ export function useHandleSocket() {
getAllChatRoomHandler,
joinChatRoomHandler,
// Game
gamePongHandler,
getAllGameRoomHandler,
joinGameRoomHandler,
} = useSetSocketHandler();

Expand Down Expand Up @@ -151,26 +142,7 @@ export function useHandleSocket() {
resetJoinGameRoom();
}, [joinGameRoom]);

useEffect(() => {
if (updateGameRoom.id.length === 0) return;
if (sockets.gameSocket === null) return;

sockets.gameSocket.emit('update_room', updateGameRoom);
resetUpdateGameRoom();
}, [updateGameRoom]);

/* ----------------- Game ----------------- */
useEffect(() => {
if (newMessage.length === 0) return;
if (sockets.gameSocket === null) return;

sockets.gameSocket.emit('ping', {
message: newMessage,
});

setNewGamePingMessage('');
}, [newGamePingMessage]);

useEffect(() => {
if (!sockets.chatSocket) {
sockets.chatSocket = createSocket('chat', {
Expand All @@ -188,9 +160,6 @@ export function useHandleSocket() {
exceptionHandler,
disconnectHandler,
});
sockets.gameSocket.on('pong', gamePongHandler);

sockets.gameSocket.on('update_game_room', getAllGameRoomHandler);
sockets.gameSocket.on('join_room', joinGameRoomHandler);
}
}, []);
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/pages/GamePage/MainScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ export class MainScene extends Phaser.Scene {
if (this.paddleLeft && this.paddleRight && this.key) {
if (this.key.up.isDown) {
this.paddleRight.y -= 10;
// this.pingHandler('PONG PONG');
sockets.gameSocket.emit('ping', { message: 'pONG POGN' });
} else if (this.key.down.isDown) this.paddleRight.y += 10;
if (this.key.shift.isDown) this.paddleLeft.y -= 10;
else if (this.key.space.isDown) this.paddleLeft.y += 10;
Expand Down
1 change: 0 additions & 1 deletion frontend/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ export { currentGamePongState } from './currentGamePongState';
export { gameRoomListState } from './gameRoomListState';
export { joinGameRoomState } from './joinGameRoomState';
export { newGameRoomState } from './newGameRoomState';
export { updateGameRoomState } from './updateGameRoomState';
export { leaveGameRoomState } from './leaveGameRoomState';
8 changes: 0 additions & 8 deletions frontend/src/store/updateGameRoomState.ts

This file was deleted.

0 comments on commit 9d7dabe

Please sign in to comment.