Esempio n. 1
0
  @Override
  public void execute(Control<BootstrapContext> control) {

    BootstrapContext bootstrap = control.getContext();

    if (bootstrap.hasProperty(BootstrapContext.STANDALONE)) {
      String value = bootstrap.isStandalone() ? "standalone" : "domain";
      analytics.trackEvent("bootstrap", "exec-mode", value);
      analytics.trackEvent("bootstrap", "console-version", Build.VERSION);

      control.proceed();
    } else {
      bootstrap.setlastError(new RuntimeException("Failed to resolve execution mode"));
      control.abort();
    }
  }
  @Override
  public void onSendMessage(final SendMessageEvent event) {
    if (event.resendOnFail()) {
      googleAnalytics.trackEvent("Chat", "Send Message");
    }
    final String message = event.getMessage();
    if (!message.isEmpty()) {
      final JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
      jsonp.requestObject(
          JsessionUrlEncoder.encode(CAConstants.HOST + "/send", "msg", message),
          new SuccessCallback<SendMessageResponse>() {

            @Override
            public void onSuccess(final SendMessageResponse response) {
              if (response.getUser() != null) {
                User.update(getEventBus(), response.getUser());
              }
              if (response.getMessage() != null) {
                final MessageWrapper msg = new MessageWrapper(response.getMessage());
                if (gameStateProvider.getGameState().swapColors()) {
                  msg.swapColor();
                }
                if (event.resendOnFail()) {
                  addToMessagesCheckQueue(msg);
                }
              }
            }
          });
    }
  }