use of games.strategy.engine.message.ChannelMessenger 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);
}
use of games.strategy.engine.message.ChannelMessenger in project triplea by triplea-game.
the class VaultTest method setUp.
@BeforeEach
public void setUp() throws IOException {
serverMessenger = new ServerMessenger("Server", 0);
serverMessenger.setAcceptNewConnections(true);
final int serverPort = serverMessenger.getLocalNode().getSocketAddress().getPort();
final String mac = MacFinder.getHashedMacAddress();
clientMessenger = new ClientMessenger("localhost", serverPort, "client1", mac);
final UnifiedMessenger serverUnifiedMessenger = new UnifiedMessenger(serverMessenger);
final UnifiedMessenger clientUnifiedMessenger = new UnifiedMessenger(clientMessenger);
serverVault = new Vault(new ChannelMessenger(serverUnifiedMessenger));
clientVault = new Vault(new ChannelMessenger(clientUnifiedMessenger));
Thread.yield();
}
use of games.strategy.engine.message.ChannelMessenger 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;
}
}
Aggregations