Search in sources :

Example 1 with LobbyClient

use of games.strategy.engine.lobby.client.LobbyClient in project triplea by triplea-game.

the class MetaSetupPanel method connectToLobby.

private void connectToLobby() {
    final LobbyServerProperties lobbyServerProperties = new LobbyServerPropertiesFetcher().fetchLobbyServerProperties();
    final LobbyLogin login = new LobbyLogin(JOptionPane.getFrameForComponent(this), lobbyServerProperties);
    final LobbyClient client = login.login();
    if (client == null) {
        return;
    }
    final LobbyFrame lobbyFrame = new LobbyFrame(client, lobbyServerProperties);
    GameRunner.hideMainFrame();
    lobbyFrame.setVisible(true);
}
Also used : LobbyClient(games.strategy.engine.lobby.client.LobbyClient) LobbyServerProperties(games.strategy.engine.lobby.client.login.LobbyServerProperties) LobbyServerPropertiesFetcher(games.strategy.engine.config.client.LobbyServerPropertiesFetcher) LobbyFrame(games.strategy.engine.lobby.client.ui.LobbyFrame) LobbyLogin(games.strategy.engine.lobby.client.login.LobbyLogin)

Example 2 with LobbyClient

use of games.strategy.engine.lobby.client.LobbyClient in project triplea by triplea-game.

the class LobbyLogin method login.

@Nullable
private LobbyClient login(final LoginPanel panel) {
    try {
        final IMessenger messenger = GameRunner.newBackgroundTaskRunner().runInBackgroundAndReturn("Connecting to lobby...", () -> login(panel.getUserName(), panel.getPassword(), panel.isAnonymousLogin()), IOException.class);
        panel.getLobbyLoginPreferences().save();
        return new LobbyClient(messenger, panel.isAnonymousLogin());
    } catch (final CouldNotLogInException e) {
        showError("Login Failed", e.getMessage() + "\n" + playerMacIdString());
        // NB: potential stack overflow due to recursive call
        return loginToServer();
    } catch (final IOException e) {
        showError("Could Not Connect", "Could not connect to lobby: " + e.getMessage());
        return null;
    } catch (final InterruptedException e) {
        Thread.currentThread().interrupt();
        return null;
    }
}
Also used : IMessenger(games.strategy.net.IMessenger) CouldNotLogInException(games.strategy.net.CouldNotLogInException) IOException(java.io.IOException) LobbyClient(games.strategy.engine.lobby.client.LobbyClient) Nullable(javax.annotation.Nullable)

Example 3 with LobbyClient

use of games.strategy.engine.lobby.client.LobbyClient in project triplea by triplea-game.

the class LobbyLogin method createAccount.

@Nullable
private LobbyClient createAccount(final CreateUpdateAccountPanel panel) {
    try {
        final IMessenger messenger = GameRunner.newBackgroundTaskRunner().runInBackgroundAndReturn("Connecting to lobby...", () -> createAccount(panel.getUserName(), panel.getPassword(), panel.getEmail()), IOException.class);
        panel.getLobbyLoginPreferences().save();
        return new LobbyClient(messenger, false);
    } catch (final CouldNotLogInException e) {
        showError("Account Creation Failed", e.getMessage());
        // NB: potential stack overflow due to recursive call
        return createAccount();
    } catch (final IOException e) {
        showError("Could Not Connect", "Could not connect to lobby: " + e.getMessage());
        return null;
    } catch (final InterruptedException e) {
        Thread.currentThread().interrupt();
        return null;
    }
}
Also used : IMessenger(games.strategy.net.IMessenger) CouldNotLogInException(games.strategy.net.CouldNotLogInException) IOException(java.io.IOException) LobbyClient(games.strategy.engine.lobby.client.LobbyClient) Nullable(javax.annotation.Nullable)

Aggregations

LobbyClient (games.strategy.engine.lobby.client.LobbyClient)3 CouldNotLogInException (games.strategy.net.CouldNotLogInException)2 IMessenger (games.strategy.net.IMessenger)2 IOException (java.io.IOException)2 Nullable (javax.annotation.Nullable)2 LobbyServerPropertiesFetcher (games.strategy.engine.config.client.LobbyServerPropertiesFetcher)1 LobbyLogin (games.strategy.engine.lobby.client.login.LobbyLogin)1 LobbyServerProperties (games.strategy.engine.lobby.client.login.LobbyServerProperties)1 LobbyFrame (games.strategy.engine.lobby.client.ui.LobbyFrame)1