@Override
  public void onActivate() {
    if (getLobby() instanceof OfflineLobby) {
      // prompt to connect to server when offline lobby activated
      FThreads.invokeInBackgroundThread(
          new Runnable() {
            @Override
            public void run() {
              final String url = NetConnectUtil.getServerUrl();
              FThreads.invokeInEdtLater(
                  new Runnable() {
                    @Override
                    public void run() {
                      if (url == null) {
                        Forge.back(); // go back to previous screen if user cancels connection
                        return;
                      }

                      final boolean joinServer = url.length() > 0;
                      final String caption =
                          joinServer ? "Connecting to server..." : "Starting server...";
                      LoadingOverlay.show(
                          caption,
                          new Runnable() {
                            @Override
                            public void run() {
                              final ChatMessage result;
                              final IOnlineChatInterface chatInterface =
                                  (IOnlineChatInterface) OnlineScreen.Chat.getScreen();
                              if (joinServer) {
                                result =
                                    NetConnectUtil.join(url, OnlineLobbyScreen.this, chatInterface);
                              } else {
                                result = NetConnectUtil.host(OnlineLobbyScreen.this, chatInterface);
                              }
                              chatInterface.addMessage(result);
                              if (!joinServer) {
                                FThreads.invokeInBackgroundThread(
                                    new Runnable() {
                                      @Override
                                      public void run() {
                                        NetConnectUtil.copyHostedServerUrl();
                                      }
                                    });
                              }
                            }
                          });
                    }
                  });
            }
          });
    }
  }
  void connectToServer() {
    final String url = NetConnectUtil.getServerUrl();
    if (url == null) {
      return;
    }

    FThreads.invokeInBackgroundThread(
        new Runnable() {
          @Override
          public void run() {
            if (url.length() > 0) {
              join(url);
            } else {
              host();
            }
          }
        });
  }