Search in sources :

Example 1 with IMessenger

use of games.strategy.net.IMessenger 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 2 with IMessenger

use of games.strategy.net.IMessenger 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)2 CouldNotLogInException (games.strategy.net.CouldNotLogInException)2 IMessenger (games.strategy.net.IMessenger)2 IOException (java.io.IOException)2 Nullable (javax.annotation.Nullable)2