File tree 1 file changed +8
-4
lines changed 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 137
137
return state . userX == state . me ? 'X' : 'O' ;
138
138
} ;
139
139
140
+ // [START open_socket]
140
141
sendMessage = function ( path , opt_param ) {
141
142
path += '?g=' + state . game_key ;
142
143
if ( opt_param ) {
147
148
xhr . send ( ) ;
148
149
} ;
149
150
151
+ onOpened = function ( ) {
152
+ sendMessage ( '/opened' ) ;
153
+ } ;
154
+ // [END open_socket]
155
+
156
+ // [START update_state]
150
157
moveInSquare = function ( id ) {
151
158
if ( isMyMove ( ) && state . board [ id ] == ' ' ) {
152
159
sendMessage ( '/move' , 'i=' + id ) ;
153
160
}
154
161
} ;
162
+ // [END update_state]
155
163
156
164
highlightSquare = function ( id ) {
157
165
if ( state . winner != "" ) {
172
180
}
173
181
} ;
174
182
175
- onOpened = function ( ) {
176
- sendMessage ( '/opened' ) ;
177
- } ;
178
-
179
183
onMessage = function ( m ) {
180
184
newState = JSON . parse ( m . data ) ;
181
185
state . board = newState . board || state . board ;
You can’t perform that action at this time.
0 commit comments