You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If no logged-in players are left, reset the game!<br><br>
85
-
If the disconnected user was the current player, restart timer and change the turn!<br><br>
86
-
Broadcast "updateState" to all other clients.<br><br>
87
-
Broadcast "playerListChange" to all other clients.<br><br>
88
-
</td>
89
-
<td>Stop the timer view.</td>
90
-
</tr>
91
-
<tr>
92
-
<td>userLogin</td>
93
-
<td>When server confirms a client is logged in</td>
94
-
<td>
95
-
Add user info to playerList.<br><br>
96
-
Send current state of the text editor to the new client, broadcasting "editorTextChange", "editorCursorChange", and "editorScrollChange" if needed.<br><br>
97
-
If first user, initialize the game!<br><br>
98
-
Broadcast "updateState" to <em>all</em> clients.<br><br>
99
-
Broadcast "playerListChange" to <em>all</em> clients.<br><br>
100
-
</td>
101
-
<td>Upon successful GitHub authentication, send "userLogin" event and user data to the server.</td>
102
-
</tr>
103
-
<tr>
104
-
<td>playerListChange</td>
105
-
<td>When server confirms a player has joined or left</td>
106
-
<td>Broadcast player list to clients, triggered by "userLogin" and "disconnect" events.</td>
107
-
<td>Update UI for player list, current turn, and next turn.</td>
108
-
</tr>
109
-
<tr>
110
-
<td>updateState</td>
111
-
<td>When game state changes and clients need to be synced up</td>
112
-
<td>Broadcast game state to <em>all</em> clients, triggered by "userLogin" and "disconnect" events.</td>
113
-
<td>
114
-
Update local state.<br><br>
115
-
Update UI for Gist link, highlighted player names, timer, current turn, and next turn.<br><br>
116
-
</td>
117
-
</tr>
118
-
<tr>
119
-
<td>turnChange</td>
120
-
<td>When the server's timer is up, pass control to the next player.</td>
121
-
<td>Broadcast turn data to <em>all</em> clients when the timer is up.</td>
122
-
<td>
123
-
Add user info to playerList.<br><br>
124
-
Fork/edit the Gist, which may broadcast "newGistLink" and update Gist UI if needed.<br><br>
125
-
Update local state.<br><br>
126
-
Toggle editor read-only mode.<br><br>
127
-
Update UI for highlighted player names, timer, current turn, and next turn.<br><br>
128
-
</td>
129
-
</tr>
130
-
<tr>
131
-
<td>createNewGist</td>
132
-
<td>When the game begins, create a new Gist on behalf of the first player.</td>
133
-
<td>Broadcast event to first player once logged in, if starting a new game.</td>
134
-
<td>
135
-
Create a Gist for the current user.<br><br>
136
-
Broadcast "newGistLink" to server.<br><br>
137
-
Update Gist UI.
138
-
</td>
139
-
</tr>
140
-
<tr>
141
-
<td>newGistLink</td>
142
-
<td>When a new Gist is created or forked, sync up clients to display the new link.</td>
143
-
<td>Update game state and broadcast "newGistLink" to all other clients.</td>
144
-
<td>Update local state and update Gist UI.</td>
145
-
</tr>
146
-
<tr>
147
-
<td>Ace Editor: change</td>
148
-
<td>When a user types in the editor</td>
149
-
<td><em>Not used</em></td>
150
-
<td>
151
-
Update editor view with new content.<br><br>
152
-
Send "editorTextChange" event with data to server.
153
-
</td>
154
-
</tr>
155
-
<tr>
156
-
<td>Ace Editor: changeCursor</td>
157
-
<td>When a user moves the editor cursor</td>
158
-
<td><em>Not used</em></td>
159
-
<td>
160
-
Update cursor in editor view.<br><br>
161
-
Send "editorCursorChange" event with data to server.
162
-
</td>
163
-
</tr>
164
-
<tr>
165
-
<td>Ace Editor: changeScrollLeft and changeScrollTop</td>
166
-
<td>When a user scrolls in the editor</td>
167
-
<td><em>Not used</em></td>
168
-
<td>
169
-
Update scroll position in editor view.<br><br>
170
-
Send "editorScrollChange" event with data to server.
171
-
</td>
172
-
</tr>
173
-
<tr>
174
-
<td>editorTextChange</td>
175
-
<td>When a user types in the editor, sync the content across all clients.</td>
176
-
<td>
177
-
Update local state.<br><br>
178
-
Verify that the data was sent from the current user -- to prevent cheating!<br><br>
179
-
Broadcast "editorTextChange" with updated content to all other clients.<br><br>
180
-
</td>
181
-
<td>Update editor view with new content.</td>
182
-
</tr>
183
-
<tr>
184
-
<td>editorCursorChange</td>
185
-
<td>When a user moves the editor cursor, sync across all clients.</td>
186
-
<td>
187
-
Update local state.<br><br>
188
-
Verify that the data was sent from the current user -- to prevent cheating!<br><br>
189
-
Broadcast "editorCursorChange" with updated content to all other clients.<br><br>
190
-
</td>
191
-
<td>Update cursor in editor view.</td>
192
-
</tr>
193
-
<tr>
194
-
<td>editorScrollChange</td>
195
-
<td>When a user scrolls in the editor, sync across all clients.</td>
196
-
<td>
197
-
Update local state.<br><br>
198
-
Verify that the data was sent from the current user -- to prevent cheating!<br><br>
199
-
Broadcast "editorScrollChange" with updated content to all other clients.<br><br>
200
-
</td>
201
-
<td>Update scroll position in editor view.</td>
202
-
</tr>
203
-
</tbody>
204
-
</table>
85
+
| Event Name | Sent By | Sent To | Data | Description |
86
+
|---|---|---|---|---|
87
+
|`playerJoined`| Client | Server |`{login, avatar_url}`| When new player completes login process |
88
+
|`playerJoined`| Server | All *other* clients |`{id, login, avatar_url}`| Update other clients with new player data |
89
+
|`gameState`| Server | One client | See game state model in section above! | Initialize game state for new player that just logged in, and trigger new gist creation if game is just starting! |
90
+
|`playerLeft`| Server | All *other* clients |`id`| Update other clients to remove disconnected player |
91
+
|`turnChange`| Server | All clients |`onDisconnect` (Boolean) | Trigger clients to change the turn |
92
+
|`newGist`| Client | Server |`{id, url, owner}`| Broadcast new Gist data |
93
+
|`editorTextChange`| Client | Server |`"current content, just a string!"`| Broadcast changes to code editor content |
|`editorScrollChange`| Client | Server |`{scrollLeft, scrollTop}`| Broadcast changes to code editor content |
96
+
|`disconnect`| Client | Server | ... | When clients disconnect from server (SocketIO function) |
97
+
|`connection`| Client | Server | ... | When clients connect to server (SocketIO function) |
98
+
205
99
206
100
## Project Log
207
101
@@ -372,3 +266,27 @@ High-level, simplified state chart:
372
266
**Milestones:**
373
267
374
268
- Created high-level UML state machine diagram, added to this README for [version 1.0.0 documentation](#version-100-documentation).
269
+
270
+
### 2017-07-03
271
+
272
+
**Today's daily learning blog post: https://learningnerd.com/2017/07/03/**
273
+
274
+
**Milestones:**
275
+
276
+
- Closed [#issue #4 ("Change game start condition to check state of the player list")](https://github.com/LearnTeachCode/mob-coding/issues/4)
277
+
278
+
- Opened [issue #29 ("Sometimes when last user disconnects (maybe while turn is changing?), server crashes")](https://github.com/LearnTeachCode/mob-coding/issues/29)
279
+
280
+
- Merged [issue #5 ("Consolidate the playerListChange and updateState events")](https://github.com/LearnTeachCode/mob-coding/issues/5) into [issue #16 ("Simplify the game state data model and events on client and server")](https://github.com/LearnTeachCode/mob-coding/issues/16) and updated issue #16.
281
+
282
+
- Finished initial rewrite of events list and game state data model, started the major refactoring task for issue #16, stripping out all the guts of this app and replacing them all!
283
+
284
+
### 2017-07-10
285
+
286
+
**Today's daily learning blog post: https://learningnerd.com/2017/07/10/**
287
+
288
+
**Milestones:**
289
+
290
+
- Main refactoring task completed! Finally closed [issue #16 ("Simplify the game state data model and events on client and server")](https://github.com/LearnTeachCode/mob-coding/issues/16), also closing [issue #18](https://github.com/LearnTeachCode/mob-coding/issues/18) and [issue #14](https://github.com/LearnTeachCode/mob-coding/issues/14) in the process!
291
+
292
+
- Added game state and updated events list for [version 1.0.0 documentation](#version-100-documentation) in this README.
0 commit comments