use of games.strategy.engine.message.RemoteName in project triplea by triplea-game.
the class ModeratorController method mutePlayerHeadlessHostBot.
@Override
public String mutePlayerHeadlessHostBot(final INode node, final String playerNameToBeMuted, final int minutes, final String hashedPassword, final String salt) {
assertUserIsAdmin();
if (serverMessenger.getServerNode().equals(node)) {
throw new IllegalStateException("Cannot do this for server node");
}
final INode modNode = MessageContext.getSender();
final String mac = getNodeMacAddress(node);
final RemoteName remoteName = RemoteHostUtils.getRemoteHostUtilsName(node);
final IRemoteHostUtils remoteHostUtils = (IRemoteHostUtils) allMessengers.getRemoteMessenger().getRemote(remoteName);
final String response = remoteHostUtils.mutePlayerHeadlessHostBot(playerNameToBeMuted, minutes, hashedPassword, salt);
logger.info(String.format((response == null ? "Successful" : "Failed (" + response + ")") + " Remote Mute of " + playerNameToBeMuted + " for " + minutes + " minutes In Headless HostBot. Host: %s IP: %s Mac: %s Mod Username: %s Mod IP: %s Mod Mac: %s", node.getName(), node.getAddress().getHostAddress(), mac, modNode.getName(), modNode.getAddress().getHostAddress(), getNodeMacAddress(modNode)));
return response;
}
use of games.strategy.engine.message.RemoteName in project triplea by triplea-game.
the class DefaultPlayerBridge method getRemoteDelegate.
@Override
public IRemote getRemoteDelegate() {
if (game.isGameOver()) {
throw new GameOverException("Game Over");
}
try {
game.getData().acquireReadLock();
try {
final IDelegate delegate = game.getData().getDelegateList().getDelegate(currentDelegate);
if (delegate == null) {
final String errorMessage = "IDelegate in DefaultPlayerBridge.getRemote() cannot be null. CurrentStep: " + stepName + ", and CurrentDelegate: " + currentDelegate;
// for some reason, client isn't getting or seeing the errors, so make sure we print it to err
// too
System.err.println(errorMessage);
// Veqryn: hope that this suffices...?
throw new IllegalStateException(errorMessage);
}
final RemoteName remoteName;
try {
remoteName = ServerGame.getRemoteName(delegate);
} catch (final Exception e) {
final String errorMessage = "IDelegate IRemote interface class returned null or was not correct interface. CurrentStep: " + stepName + ", and CurrentDelegate: " + currentDelegate;
// for some reason, client isn't getting or seeing the errors, so make sure we print it to err
// too
System.err.println(errorMessage);
ClientLogger.logQuietly(errorMessage, e);
throw new IllegalStateException(errorMessage, e);
}
return getRemoteThatChecksForGameOver(game.getRemoteMessenger().getRemote(remoteName));
} finally {
game.getData().releaseReadLock();
}
} catch (final MessengerException me) {
throw new GameOverException("Game Over!");
}
}
use of games.strategy.engine.message.RemoteName in project triplea by triplea-game.
the class ChannelMessengerTest method testMultipleChannels.
@Test
public void testMultipleChannels() {
final RemoteName testRemote2 = new RemoteName(IChannelBase.class, "testRemote2");
final RemoteName testRemote3 = new RemoteName(IChannelBase.class, "testRemote3");
final ChannelSubscribor subscribor2 = new ChannelSubscribor();
clientChannelMessenger.registerChannelSubscriber(subscribor2, testRemote2);
final ChannelSubscribor subscribor3 = new ChannelSubscribor();
clientChannelMessenger.registerChannelSubscriber(subscribor3, testRemote3);
assertHasChannel(testRemote2, unifiedMessengerHub);
assertHasChannel(testRemote3, unifiedMessengerHub);
final IChannelBase channelTest2 = (IChannelBase) serverChannelMessenger.getChannelBroadcastor(testRemote2);
channelTest2.testNoParams();
assertCallCountIs(subscribor2, 1);
final IChannelBase channelTest3 = (IChannelBase) serverChannelMessenger.getChannelBroadcastor(testRemote3);
channelTest3.testNoParams();
assertCallCountIs(subscribor3, 1);
}
use of games.strategy.engine.message.RemoteName in project triplea by triplea-game.
the class ChannelMessengerTest method testLocalCall.
@Test
public void testLocalCall() {
final RemoteName descriptor = new RemoteName(IChannelBase.class, "testLocalCall");
serverChannelMessenger.registerChannelSubscriber(new ChannelSubscribor(), descriptor);
final IChannelBase subscribor = (IChannelBase) serverChannelMessenger.getChannelBroadcastor(descriptor);
subscribor.testNoParams();
subscribor.testPrimitives(1, (short) 0, 1, (byte) 1, true, (float) 1.0);
subscribor.testString("a");
}
use of games.strategy.engine.message.RemoteName in project triplea by triplea-game.
the class RemoteMessengerTest method testRegisterUnregister.
@Test
public void testRegisterUnregister() {
final TestRemote testRemote = new TestRemote();
final RemoteName test = new RemoteName(ITestRemote.class, "test");
remoteMessenger.registerRemote(testRemote, test);
assertTrue(remoteMessenger.hasLocalImplementor(test));
remoteMessenger.unregisterRemote(test);
assertFalse(remoteMessenger.hasLocalImplementor(test));
}
Aggregations