Package com.kolakcc.loljclient.controller

Source Code of com.kolakcc.loljclient.controller.StoreController

package com.kolakcc.loljclient.controller;

import java.awt.Desktop;
import java.net.URI;
import java.util.concurrent.ExecutionException;

import com.gvaneyck.rtmp.encoding.TypedObject;
import com.kolakcc.loljclient.StartupClass;
import com.kolakcc.loljclient.util.NamedSwingWorker;

public class StoreController extends KolaController {
  public StoreController() {
    new NamedSwingWorker<TypedObject,Void>("Store URL") {
      @Override
      protected TypedObject doInBackground() throws Exception {
        int id = StartupClass.Client.invoke("loginService", "getStoreUrl", new Object[] { });
        return StartupClass.Client.getResult(id);
      }
      @Override
      protected void done() {
        try {
          String url = get().getTO("data").getString("body");
          System.out.println(url);
         
          //TODO: write a better client for the shop.... will probably be a pain
          Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
            if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
                try {
                    desktop.browse(new URI(url));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (InterruptedException | ExecutionException e) {
          e.printStackTrace();
        }
      }
    }.execute();
  }
}
TOP

Related Classes of com.kolakcc.loljclient.controller.StoreController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.