Search in sources :

Example 1 with CouldNotLogInException

use of games.strategy.net.CouldNotLogInException in project triplea by triplea-game.

the class Decoder method sendQuarantine.

private void sendQuarantine(final SocketChannel channel, final QuarantineConversation conversation, final MessageHeader header) {
    final Action a = conversation.message(header.getMessage());
    if (a == Action.TERMINATE) {
        conversation.close();
        // we need to indicate the channel was closed
        errorReporter.error(channel, new CouldNotLogInException());
    } else if (a == Action.UNQUARANTINE) {
        nioSocket.unquarantine(channel, conversation);
        quarantine.remove(channel);
    }
}
Also used : Action(games.strategy.net.nio.QuarantineConversation.Action) CouldNotLogInException(games.strategy.net.CouldNotLogInException)

Example 2 with CouldNotLogInException

use of games.strategy.net.CouldNotLogInException in project triplea by triplea-game.

the class ClientModel method createClientMessenger.

boolean createClientMessenger(Component ui) {
    gameDataOnStartup = gameSelectorModel.getGameData();
    gameSelectorModel.setCanSelect(false);
    ui = JOptionPane.getFrameForComponent(ui);
    this.ui = ui;
    // load in the saved name!
    final ClientProps props = getProps(ui);
    if (props == null) {
        gameSelectorModel.setCanSelect(true);
        cancel();
        return false;
    }
    final String name = props.getName();
    logger.log(Level.FINE, "Client playing as:" + name);
    ClientSetting.PLAYER_NAME.save(name);
    ClientSetting.flush();
    final int port = props.getPort();
    if (port >= 65536 || port <= 0) {
        EventThreadJOptionPane.showMessageDialog(ui, "Invalid Port: " + port, "Error", JOptionPane.ERROR_MESSAGE);
        return false;
    }
    final String address = props.getHost();
    try {
        final String mac = MacFinder.getHashedMacAddress();
        messenger = new ClientMessenger(address, port, name, mac, objectStreamFactory, new ClientLogin(this.ui));
    } catch (final CouldNotLogInException e) {
        EventThreadJOptionPane.showMessageDialog(ui, e.getMessage());
        return false;
    } catch (final Exception ioe) {
        ioe.printStackTrace(System.out);
        EventThreadJOptionPane.showMessageDialog(ui, "Unable to connect:" + ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        return false;
    }
    messenger.addErrorListener(this);
    final UnifiedMessenger unifiedMessenger = new UnifiedMessenger(messenger);
    channelMessenger = new ChannelMessenger(unifiedMessenger);
    remoteMessenger = new RemoteMessenger(unifiedMessenger);
    channelMessenger.registerChannelSubscriber(channelListener, IClientChannel.CHANNEL_NAME);
    chatPanel = new ChatPanel(messenger, channelMessenger, remoteMessenger, ServerModel.CHAT_NAME, Chat.ChatSoundProfile.GAME_CHATROOM);
    if (getIsServerHeadlessTest()) {
        gameSelectorModel.setClientModelForHostBots(this);
        ((ChatPanel) chatPanel).getChatMessagePanel().addServerMessage("Welcome to an automated dedicated host service (a host bot). " + "\nIf anyone disconnects, the autosave will be reloaded (a save might be loaded right now). " + "\nYou can get the current save, or you can load a save (only saves that it has the map for).");
    }
    remoteMessenger.registerRemote(observerWaitingToJoin, ServerModel.getObserverWaitingToStartName(messenger.getLocalNode()));
    // save this, it will be cleared later
    gameDataOnStartup = gameSelectorModel.getGameData();
    final IServerStartupRemote serverStartup = getServerStartup();
    final PlayerListing players = serverStartup.getPlayerListing();
    internalPlayerListingChanged(players);
    if (!serverStartup.isGameStarted(messenger.getLocalNode())) {
        remoteMessenger.unregisterRemote(ServerModel.getObserverWaitingToStartName(messenger.getLocalNode()));
    }
    gameSelectorModel.setIsHostHeadlessBot(hostIsHeadlessBot);
    return true;
}
Also used : RemoteMessenger(games.strategy.engine.message.RemoteMessenger) IRemoteMessenger(games.strategy.engine.message.IRemoteMessenger) UnifiedMessenger(games.strategy.engine.message.unifiedmessenger.UnifiedMessenger) CouldNotLogInException(games.strategy.net.CouldNotLogInException) IChatPanel(games.strategy.engine.chat.IChatPanel) ChatPanel(games.strategy.engine.chat.ChatPanel) IOException(java.io.IOException) CouldNotLogInException(games.strategy.net.CouldNotLogInException) IChannelMessenger(games.strategy.engine.message.IChannelMessenger) ChannelMessenger(games.strategy.engine.message.ChannelMessenger) PlayerListing(games.strategy.engine.framework.message.PlayerListing) ClientMessenger(games.strategy.net.ClientMessenger) IClientMessenger(games.strategy.net.IClientMessenger) ClientLogin(games.strategy.engine.framework.startup.login.ClientLogin)

Example 3 with CouldNotLogInException

use of games.strategy.net.CouldNotLogInException 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 4 with CouldNotLogInException

use of games.strategy.net.CouldNotLogInException 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

CouldNotLogInException (games.strategy.net.CouldNotLogInException)4 IOException (java.io.IOException)3 LobbyClient (games.strategy.engine.lobby.client.LobbyClient)2 IMessenger (games.strategy.net.IMessenger)2 Nullable (javax.annotation.Nullable)2 ChatPanel (games.strategy.engine.chat.ChatPanel)1 IChatPanel (games.strategy.engine.chat.IChatPanel)1 PlayerListing (games.strategy.engine.framework.message.PlayerListing)1 ClientLogin (games.strategy.engine.framework.startup.login.ClientLogin)1 ChannelMessenger (games.strategy.engine.message.ChannelMessenger)1 IChannelMessenger (games.strategy.engine.message.IChannelMessenger)1 IRemoteMessenger (games.strategy.engine.message.IRemoteMessenger)1 RemoteMessenger (games.strategy.engine.message.RemoteMessenger)1 UnifiedMessenger (games.strategy.engine.message.unifiedmessenger.UnifiedMessenger)1 ClientMessenger (games.strategy.net.ClientMessenger)1 IClientMessenger (games.strategy.net.IClientMessenger)1 Action (games.strategy.net.nio.QuarantineConversation.Action)1