Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions appengine/channel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
return state.userX == state.me ? 'X' : 'O';
};

// [START open_socket]
sendMessage = function(path, opt_param) {
path += '?g=' + state.game_key;
if (opt_param) {
Expand All @@ -147,11 +148,18 @@
xhr.send();
};

onOpened = function() {
sendMessage('/opened');
};
// [END open_socket]

// [START update_state]
moveInSquare = function(id) {
if (isMyMove() && state.board[id] == ' ') {
sendMessage('/move', 'i=' + id);
}
};
// [END update_state]

highlightSquare = function(id) {
if (state.winner != "") {
Expand All @@ -172,10 +180,6 @@
}
};

onOpened = function() {
sendMessage('/opened');
};

onMessage = function(m) {
newState = JSON.parse(m.data);
state.board = newState.board || state.board;
Expand Down