Skip to content

Commit 77e00df

Browse files
committed
Project log updates
1 parent 6c82ede commit 77e00df

File tree

1 file changed

+60
-142
lines changed

1 file changed

+60
-142
lines changed

README.md

+60-142
Original file line numberDiff line numberDiff line change
@@ -58,150 +58,44 @@ High-level, simplified state chart:
5858

5959
![Mob coding version 1.0.0 flowchart](https://learningnerd.com/images/mobcoding-flowchart-2017-06-29.svg)
6060

61+
### Game state
62+
63+
**Note:** As of 2017-07-10, client-side game state currently handles the editor content differently, using a separate Ace Editor object instead.
64+
65+
```
66+
{
67+
timeRemaining,
68+
turnIndex,
69+
currentGist: {id, url, owner},
70+
players:
71+
[
72+
{id, login,avatar_url}, { ... }, { ... }, ...
73+
],
74+
editor:
75+
{
76+
content,
77+
cursorAndSelection: { cursor: {column, row}, range: { end: {column, row}, start: {column, row} },
78+
scroll: {scrollLeft, scrollTop}
79+
}
80+
}
81+
```
82+
6183
### Events List
6284

63-
<table>
64-
<thead>
65-
<tr>
66-
<th>Event Name</th>
67-
<th>Description</th>
68-
<th>Server Actions</th>
69-
<th>Client Actions</th>
70-
</tr>
71-
</thead>
72-
<tbody>
73-
<tr>
74-
<td>connection</td>
75-
<td>When client connects to SocketIO</td>
76-
<td>Start the whole app!</td>
77-
<td><em>Not used</em></td>
78-
</tr>
79-
<tr>
80-
<td>disconnect</td>
81-
<td>When a client disconnects from SocketIO</td>
82-
<td>
83-
Remove disconnected user from playerList.<br><br>
84-
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 |
94+
| `editorCursorChange` | Client | Server | `{ cursor: {column, row}, range: { end: {column, row}, start: {column, row} }` | Broadcast cursor moves or selection changes |
95+
| `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+
20599

206100
## Project Log
207101

@@ -372,3 +266,27 @@ High-level, simplified state chart:
372266
**Milestones:**
373267

374268
- 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

Comments
 (0)