Search in sources :

Example 1 with NullModeratorController

use of games.strategy.engine.lobby.server.NullModeratorController in project triplea by triplea-game.

the class ChatIntegrationTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    serverMessenger = new ServerMessenger("Server", 0);
    serverMessenger.setAcceptNewConnections(true);
    final int serverPort = serverMessenger.getLocalNode().getSocketAddress().getPort();
    final String mac = MacFinder.getHashedMacAddress();
    client1Messenger = new ClientMessenger("localhost", serverPort, "client1", mac);
    client2Messenger = new ClientMessenger("localhost", serverPort, "client2", mac);
    final UnifiedMessenger serverUnifiedMessenger = new UnifiedMessenger(serverMessenger);
    serverRemoteMessenger = new RemoteMessenger(serverUnifiedMessenger);
    serverChannelMessenger = new ChannelMessenger(serverUnifiedMessenger);
    final UnifiedMessenger client1UnifiedMessenger = new UnifiedMessenger(client1Messenger);
    client1RemoteMessenger = new RemoteMessenger(client1UnifiedMessenger);
    client1ChannelMessenger = new ChannelMessenger(client1UnifiedMessenger);
    final UnifiedMessenger client2UnifiedMessenger = new UnifiedMessenger(client2Messenger);
    client2RemoteMessenger = new RemoteMessenger(client2UnifiedMessenger);
    client2ChannelMessenger = new ChannelMessenger(client2UnifiedMessenger);
    serverModeratorController = new NullModeratorController(serverMessenger, null);
    serverModeratorController.register(serverRemoteMessenger);
}
Also used : IRemoteMessenger(games.strategy.engine.message.IRemoteMessenger) RemoteMessenger(games.strategy.engine.message.RemoteMessenger) UnifiedMessenger(games.strategy.engine.message.unifiedmessenger.UnifiedMessenger) ServerMessenger(games.strategy.net.ServerMessenger) IServerMessenger(games.strategy.net.IServerMessenger) NullModeratorController(games.strategy.engine.lobby.server.NullModeratorController) IChannelMessenger(games.strategy.engine.message.IChannelMessenger) ChannelMessenger(games.strategy.engine.message.ChannelMessenger) ClientMessenger(games.strategy.net.ClientMessenger) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with NullModeratorController

use of games.strategy.engine.lobby.server.NullModeratorController in project triplea by triplea-game.

the class ServerModel method createServerMessenger.

/**
 * UI can be null. We use it as the parent for message dialogs we show.
 * If you have a component displayed, use it.
 */
boolean createServerMessenger(@Nullable final Component ui, @Nonnull final ServerConnectionProps props) {
    this.ui = (ui == null) ? null : JOptionPane.getFrameForComponent(ui);
    try {
        serverMessenger = new ServerMessenger(props.getName(), props.getPort(), objectStreamFactory);
        final ClientLoginValidator clientLoginValidator = new ClientLoginValidator(serverMessenger);
        clientLoginValidator.setGamePassword(props.getPassword());
        serverMessenger.setLoginValidator(clientLoginValidator);
        serverMessenger.addErrorListener(this);
        serverMessenger.addConnectionChangeListener(this);
        final UnifiedMessenger unifiedMessenger = new UnifiedMessenger(serverMessenger);
        remoteMessenger = new RemoteMessenger(unifiedMessenger);
        remoteMessenger.registerRemote(serverStartupRemote, SERVER_REMOTE_NAME);
        channelMessenger = new ChannelMessenger(unifiedMessenger);
        final NullModeratorController moderatorController = new NullModeratorController(serverMessenger, null);
        moderatorController.register(remoteMessenger);
        chatController = new ChatController(CHAT_NAME, serverMessenger, remoteMessenger, channelMessenger, moderatorController);
        if (ui == null && headless) {
            chatPanel = new HeadlessChat(serverMessenger, channelMessenger, remoteMessenger, CHAT_NAME, Chat.ChatSoundProfile.GAME_CHATROOM);
        } else {
            chatPanel = new ChatPanel(serverMessenger, channelMessenger, remoteMessenger, CHAT_NAME, Chat.ChatSoundProfile.GAME_CHATROOM);
        }
        serverMessenger.setAcceptNewConnections(true);
        gameDataChanged();
        return true;
    } catch (final IOException ioe) {
        ioe.printStackTrace(System.out);
        if (headless) {
            System.out.println("Unable to create server socket:" + ioe.getMessage());
        } else {
            JOptionPane.showMessageDialog(ui, "Unable to create server socket:" + ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
        return false;
    }
}
Also used : RemoteMessenger(games.strategy.engine.message.RemoteMessenger) IRemoteMessenger(games.strategy.engine.message.IRemoteMessenger) UnifiedMessenger(games.strategy.engine.message.unifiedmessenger.UnifiedMessenger) ChatController(games.strategy.engine.chat.ChatController) ServerMessenger(games.strategy.net.ServerMessenger) IServerMessenger(games.strategy.net.IServerMessenger) NullModeratorController(games.strategy.engine.lobby.server.NullModeratorController) HeadlessChat(games.strategy.engine.chat.HeadlessChat) IChannelMessenger(games.strategy.engine.message.IChannelMessenger) ChannelMessenger(games.strategy.engine.message.ChannelMessenger) IChatPanel(games.strategy.engine.chat.IChatPanel) ChatPanel(games.strategy.engine.chat.ChatPanel) IOException(java.io.IOException) ClientLoginValidator(games.strategy.engine.framework.startup.login.ClientLoginValidator)

Aggregations

NullModeratorController (games.strategy.engine.lobby.server.NullModeratorController)2 ChannelMessenger (games.strategy.engine.message.ChannelMessenger)2 IChannelMessenger (games.strategy.engine.message.IChannelMessenger)2 IRemoteMessenger (games.strategy.engine.message.IRemoteMessenger)2 RemoteMessenger (games.strategy.engine.message.RemoteMessenger)2 UnifiedMessenger (games.strategy.engine.message.unifiedmessenger.UnifiedMessenger)2 IServerMessenger (games.strategy.net.IServerMessenger)2 ServerMessenger (games.strategy.net.ServerMessenger)2 ChatController (games.strategy.engine.chat.ChatController)1 ChatPanel (games.strategy.engine.chat.ChatPanel)1 HeadlessChat (games.strategy.engine.chat.HeadlessChat)1 IChatPanel (games.strategy.engine.chat.IChatPanel)1 ClientLoginValidator (games.strategy.engine.framework.startup.login.ClientLoginValidator)1 ClientMessenger (games.strategy.net.ClientMessenger)1 IOException (java.io.IOException)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1