Esempio n. 1
0
  private void startServer() {

    if (server == null) {
      AssetManager am =
          (AssetManager)
              AndroidServiceLocator.GetInstance()
                  .GetService(AndroidServiceLocator.SERVICE_ANDROID_ASSET_MANAGER);
      if (serverProperties == null) {
        serverProperties = new Properties();
        try {
          serverProperties.load(am.open(SERVER_PROPERTIES));
        } catch (IOException ex) {
          LOG.Log(Module.GUI, ex.toString());
        }
      }
      LOG.Log(
          Module.GUI,
          "The Port is: " + serverProperties.getProperty(SERVER_PORT_PROPERTY, "Missing"));
      try {
        serverPort = Integer.parseInt(serverProperties.getProperty(SERVER_PORT_PROPERTY));
        server = new HttpServer(serverPort, this, this.appView);
        server.start();
      } catch (Exception ex) {
        LOG.Log(Module.GUI, ex.toString());
      }
      LOG.Log(Module.GUI, "Server started.");
    }
  }
Esempio n. 2
0
  private void stopServer() {

    if (server != null) {
      server.shutdown();
      server = null;
      LOG.Log(Module.GUI, "Server stopped.");
    }
  }
  private void _stopServer(boolean sendToBackground) {

    // ******* TO BE REVIEW, this while is not well programmed, needs to be changed and assure
    // server is stopped after all
    while (server != null && !this.isWebviewLoadingPage()) {
      // [MOBPLAT-179] wait to stop server while page is still loading
      LOG.Log(Module.GUI, "App finished loading, server could be stopped");

      server.shutdown();
      server = null;
      LOG.Log(Module.GUI, "Server stopped.");

      if (sendToBackground) {
        this.activityManager.loadUrlIntoWebView(
            "javascript:try{Appverse._toBackground()}catch(e){}");
      }
    }
  }