Search in sources :

Example 1 with AnalysisRequestStatus

use of com.playshogi.website.gwt.shared.models.AnalysisRequestStatus in project playshogi by Tellmarch.

the class ViewKifuActivity method onRequestKifuEvaluationEvent.

@EventHandler
public void onRequestKifuEvaluationEvent(final RequestKifuEvaluationEvent event) {
    GWT.log("View Kifu Activity Handling RequestKifuEvaluationEvent");
    String usf = UsfFormat.INSTANCE.write(viewKifuView.getNavigationController().getGameNavigation().getGameTree());
    kifuService.requestKifuAnalysis(sessionInformation.getSessionId(), usf, new AsyncCallback<AnalysisRequestStatus>() {

        @Override
        public void onFailure(Throwable throwable) {
            GWT.log("ViewKifu - error requesting kifu evaluation");
        }

        @Override
        public void onSuccess(AnalysisRequestStatus result) {
            GWT.log("ViewKifu - kifu evaluation result: " + result);
            if (result.isDenied()) {
                eventBus.fireEvent(new KifuEvaluationEvent(new AnalysisRequestResult(result), kifuId));
            } else if (result.needToWait()) {
                Timer timer = new Timer() {

                    @Override
                    public void run() {
                        queryKifuAnalysisResults(usf, this);
                    }
                };
                timer.scheduleRepeating(1000);
            } else {
                queryKifuAnalysisResults(usf, null);
            }
        }
    });
}
Also used : Timer(com.google.gwt.user.client.Timer) AnalysisRequestResult(com.playshogi.website.gwt.shared.models.AnalysisRequestResult) AnalysisRequestStatus(com.playshogi.website.gwt.shared.models.AnalysisRequestStatus) EventHandler(com.google.web.bindery.event.shared.binder.EventHandler)

Aggregations

Timer (com.google.gwt.user.client.Timer)1 EventHandler (com.google.web.bindery.event.shared.binder.EventHandler)1 AnalysisRequestResult (com.playshogi.website.gwt.shared.models.AnalysisRequestResult)1 AnalysisRequestStatus (com.playshogi.website.gwt.shared.models.AnalysisRequestStatus)1