public void afterAnimation() { if (stateToSetAfterAnimation.getLastMoveWasOppositeCapture()) graphics.oppositeCaptureSound(); state = stateToSetAfterAnimation.copyState(); updateBoard(); if (aiMatch) sendMoveToServerAI(lastMove, state); }
public void sendMoveToServer(Integer chosenIndex, String stateString) { final Integer fChosenIndex = chosenIndex; final String fStateString = stateString; if (aiMatch) { sendMoveToServerAI(chosenIndex, State.deserialize(stateString)); return; } // secured against xsrf attacks // see http://www.gwtproject.org/doc/latest/DevGuideSecurityRpcXsrf.html XsrfTokenServiceAsync xsrf = (XsrfTokenServiceAsync) GWT.create(XsrfTokenService.class); ((ServiceDefTarget) xsrf).setServiceEntryPoint(GWT.getModuleBaseURL() + "gwt/xsrf"); xsrf.getNewXsrfToken( new AsyncCallback<XsrfToken>() { public void onSuccess(XsrfToken token) { ((HasRpcToken) mancalaService).setRpcToken(token); mancalaService.makeMove( userId, matchId, fChosenIndex, fStateString, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { Window.alert("Server error!"); } @Override public void onSuccess(Void result) { // updateMatchList(); } }); } public void onFailure(Throwable caught) { Window.alert("Error retrieving xsrf token! Please try again later."); } }); }