@@ -110,7 +110,7 @@ playerJoined Server All other clients {id, login, avatar_url} Update other
110
110
gameState Server One client See game state model! Initialize game state for new player that just logged in,
111
111
and trigger new gist creation if game is just starting!
112
112
playerLeft Server All other clients id Update other clients to remove disconnected player
113
- turnChange Server All clients null ??? Trigger clients to change the turn
113
+ turnChange Server All clients onDisconnect (Boolean) Trigger clients to change the turn
114
114
newGist Client Server {id, url, owner} Broadcast new Gist data
115
115
editorTextChange Client Server "just a string!" Broadcast changes to code editor content
116
116
editorScrollChange Client Server {scrollLeft, scrollTop} Broadcast changes to code editor content
@@ -192,8 +192,8 @@ io.on('connection', function (socket) {
192
192
// Restart the timer
193
193
timerId = startTurnTimer ( timerId , turnDuration ) ;
194
194
195
- // Change the turn, including ID of disconnected player to send to clients
196
- changeTurn ( socket . id ) ;
195
+ // Change the turn, including the onDisconnect=true flag to signal clients NOT to fork/edit the Gist on this turn change
196
+ changeTurn ( true ) ;
197
197
}
198
198
199
199
} else {
@@ -261,11 +261,11 @@ io.on('connection', function (socket) {
261
261
/* -------------------------------------------------
262
262
FUNCTIONS
263
263
---------------------------------------------------- */
264
- function changeTurn ( disconnectedPlayerId ) {
264
+ function changeTurn ( onDisconnect ) {
265
265
gameState . turnIndex = ( gameState . turnIndex + 1 ) % gameState . players . length ;
266
266
267
267
// Broadcast turnChange to ALL clients, with disconnected player ID (which exists only if current player disconnected):
268
- io . emit ( 'turnChange' , disconnectedPlayerId ) ;
268
+ io . emit ( 'turnChange' , onDisconnect ) ;
269
269
}
270
270
271
271
// Initializes the turn and turn timer, returns timerId
0 commit comments