Search in sources :

Example 16 with RemoteName

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;
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) INode(games.strategy.net.INode)

Example 17 with RemoteName

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!");
    }
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) MessengerException(games.strategy.engine.message.MessengerException) GameOverException(games.strategy.engine.GameOverException) IDelegate(games.strategy.engine.delegate.IDelegate) RemoteNotFoundException(games.strategy.engine.message.RemoteNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) GameOverException(games.strategy.engine.GameOverException) MessengerException(games.strategy.engine.message.MessengerException)

Example 18 with RemoteName

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);
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) IChannelSubscribor(games.strategy.engine.message.IChannelSubscribor) Test(org.junit.jupiter.api.Test)

Example 19 with RemoteName

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");
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) IChannelSubscribor(games.strategy.engine.message.IChannelSubscribor) Test(org.junit.jupiter.api.Test)

Example 20 with RemoteName

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));
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) Test(org.junit.jupiter.api.Test)

Aggregations

RemoteName (games.strategy.engine.message.RemoteName)28 Test (org.junit.jupiter.api.Test)14 INode (games.strategy.net.INode)7 ClientMessenger (games.strategy.net.ClientMessenger)5 IChannelSubscribor (games.strategy.engine.message.IChannelSubscribor)4 RemoteMessenger (games.strategy.engine.message.RemoteMessenger)4 RemoteNotFoundException (games.strategy.engine.message.RemoteNotFoundException)4 IServerMessenger (games.strategy.net.IServerMessenger)4 ServerMessenger (games.strategy.net.ServerMessenger)4 ConnectionLostException (games.strategy.engine.message.ConnectionLostException)2 RemoteMethodCall (games.strategy.engine.message.RemoteMethodCall)2 GameOverException (games.strategy.engine.GameOverException)1 PlayerID (games.strategy.engine.data.PlayerID)1 PlayerList (games.strategy.engine.data.PlayerList)1 IDelegate (games.strategy.engine.delegate.IDelegate)1 DefaultPlayerBridge (games.strategy.engine.gamePlayer.DefaultPlayerBridge)1 IGamePlayer (games.strategy.engine.gamePlayer.IGamePlayer)1 IPlayerBridge (games.strategy.engine.gamePlayer.IPlayerBridge)1 ChannelMessenger (games.strategy.engine.message.ChannelMessenger)1 HubInvoke (games.strategy.engine.message.HubInvoke)1