@@ -11,7 +11,6 @@ export const initializeEventHandlers = (gameSession) => {
11
11
// Event handler for the socket connection
12
12
socket . on ( 'connect' , ( ) => {
13
13
isConnected = true ;
14
- console . log ( 'Connected to server' ) ;
15
14
} ) ;
16
15
17
16
// Event handler for the socket disconnection
@@ -28,11 +27,7 @@ export const initializeEventHandlers = (gameSession) => {
28
27
if ( data && data . gameId ) {
29
28
if ( data . gameId === gameSession . gameId ) {
30
29
gameSession . handleGameStart ( ) ;
31
- } else {
32
- console . warn ( `Received game start for different game, was ${ data . gameId } , expected ${ gameSession . gameId } ` ) ;
33
- }
34
- } else {
35
- console . error ( 'Received malformed game_start data:' , data ) ;
30
+ }
36
31
}
37
32
} catch ( error ) {
38
33
console . error ( 'Error handling game_start:' , error ) ;
@@ -50,11 +45,7 @@ export const initializeEventHandlers = (gameSession) => {
50
45
if ( data && data . gameId ) {
51
46
if ( data . gameId === gameSession . gameId ) {
52
47
gameSession . handleGameStateUpdate ( data ) ;
53
- } else {
54
- console . warn ( `Received game state for different game, was ${ data . gameId } , expected ${ gameSession . gameId } ` ) ;
55
48
}
56
- } else {
57
- console . error ( 'Received malformed send_game_state data:' , data ) ;
58
49
}
59
50
} catch ( error ) {
60
51
console . error ( 'Error handling send_game_state:' , error ) ;
@@ -67,11 +58,7 @@ export const initializeEventHandlers = (gameSession) => {
67
58
if ( data && data . gameId ) {
68
59
if ( data . gameId === gameSession . gameId ) {
69
60
gameSession . handleScoreUpdate ( data ) ;
70
- } else {
71
- console . warn ( `Received score update for different game, was ${ data . gameId } , expected ${ gameSession . gameId } ` ) ;
72
61
}
73
- } else {
74
- console . error ( 'Received malformed score data:' , data ) ;
75
62
}
76
63
} catch ( error ) {
77
64
console . error ( 'Error handling score update:' , error ) ;
@@ -85,11 +72,7 @@ export const initializeEventHandlers = (gameSession) => {
85
72
if ( data . gameId === gameSession . gameId && gameSession . inProgress ) {
86
73
console . info ( `Player ${ data . quittingPlayerId } has quit the game.` ) ;
87
74
gameSession . handleOpponentQuit ( data ) ;
88
- } else {
89
- console . warn ( `Received quit game for different game, was ${ data . gameId } , expected ${ gameSession . gameId } ` ) ;
90
- }
91
- } else {
92
- console . error ( 'Received malformed quit_game data:' , data ) ;
75
+ }
93
76
}
94
77
} catch ( error ) {
95
78
console . error ( 'Error handling quit_game:' , error ) ;
@@ -102,16 +85,11 @@ export const initializeEventHandlers = (gameSession) => {
102
85
if ( data && data . gameId ) {
103
86
if ( data . gameId === gameSession . gameId ) {
104
87
gameSession . inProgress = false ;
105
- console . info ( `Game ${ data . gameId } has been cancelled.` ) ;
106
88
gameSession . handleCancelGame ( data ) ;
107
89
setTimeout ( ( ) => {
108
90
endGame ( ) ;
109
91
} , 2000 ) ;
110
- } else {
111
- console . warn ( `Received cancel game for different game, was ${ data . gameId } , expected ${ gameSession . gameId } ` ) ;
112
- }
113
- } else {
114
- console . error ( 'Received malformed cancel_game data:' , data ) ;
92
+ }
115
93
}
116
94
} catch ( error ) {
117
95
console . error ( 'Error handling cancel_game:' , error ) ;
@@ -124,11 +102,7 @@ export const initializeEventHandlers = (gameSession) => {
124
102
if ( data && data . game_id ) {
125
103
if ( data . gameId === gameSession . game_id ) {
126
104
gameSession . handleGameOver ( data ) ;
127
- } else {
128
- console . warn ( `Received game over for different game, was ${ data . game_id } , expected ${ gameSession . gameId } ` ) ;
129
- }
130
- } else {
131
- console . error ( 'Received malformed game_over data:' , data ) ;
105
+ }
132
106
}
133
107
} catch ( error ) {
134
108
console . error ( 'Error handling game_over:' , error ) ;
@@ -179,7 +153,6 @@ export const cleanupEventHandlers = () => {
179
153
socket . off ( 'cancel_game' ) ;
180
154
socket . off ( 'error' ) ;
181
155
socket . off ( 'invalid_token' ) ;
182
- socket . off ( 'game_defaults' )
183
156
if ( beforeUnloadHandler ) {
184
157
window . removeEventListener ( 'beforeunload' , beforeUnloadHandler ) ;
185
158
beforeUnloadHandler = null ; // Clear the handler reference
0 commit comments