Search in sources :

Example 21 with RemoteName

use of games.strategy.engine.message.RemoteName in project triplea by triplea-game.

the class ServerGame method addDelegateMessenger.

public void addDelegateMessenger(final IDelegate delegate) {
    final Class<? extends IRemote> remoteType = delegate.getRemoteType();
    // if its null then it shouldn't be added as an IRemote
    if (remoteType == null) {
        return;
    }
    final Object wrappedDelegate = delegateExecutionManager.createInboundImplementation(delegate, new Class<?>[] { delegate.getRemoteType() });
    final RemoteName descriptor = getRemoteName(delegate);
    remoteMessenger.registerRemote(wrappedDelegate, descriptor);
}
Also used : RemoteName(games.strategy.engine.message.RemoteName)

Example 22 with RemoteName

use of games.strategy.engine.message.RemoteName in project triplea by triplea-game.

the class AbstractGame method setupLocalPlayers.

private void setupLocalPlayers(final Set<IGamePlayer> localPlayers) {
    final PlayerList playerList = gameData.getPlayerList();
    for (final IGamePlayer gp : localPlayers) {
        final PlayerID player = playerList.getPlayerId(gp.getName());
        gamePlayers.put(player, gp);
        final IPlayerBridge bridge = new DefaultPlayerBridge(this);
        gp.initialize(bridge, player);
        final RemoteName descriptor = ServerGame.getRemoteName(gp.getPlayerId(), gameData);
        remoteMessenger.registerRemote(gp, descriptor);
    }
}
Also used : IGamePlayer(games.strategy.engine.gamePlayer.IGamePlayer) DefaultPlayerBridge(games.strategy.engine.gamePlayer.DefaultPlayerBridge) PlayerID(games.strategy.engine.data.PlayerID) RemoteName(games.strategy.engine.message.RemoteName) PlayerList(games.strategy.engine.data.PlayerList) IPlayerBridge(games.strategy.engine.gamePlayer.IPlayerBridge)

Example 23 with RemoteName

use of games.strategy.engine.message.RemoteName in project triplea by triplea-game.

the class ClientMessenger method bareBonesSendMessageToServer.

private void bareBonesSendMessageToServer(final String methodName, final Object... messages) {
    final List<Object> args = new ArrayList<>();
    final Class<?>[] argTypes = new Class<?>[messages.length];
    for (int i = 0; i < messages.length; i++) {
        final Object message = messages[i];
        args.add(message);
        argTypes[i] = args.get(i).getClass();
    }
    final RemoteName rn = ServerModel.SERVER_REMOTE_NAME;
    final RemoteMethodCall call = new RemoteMethodCall(rn.getName(), methodName, args.toArray(), argTypes, rn.getClazz());
    final HubInvoke hubInvoke = new HubInvoke(null, false, call);
    send(hubInvoke, getServerNode());
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) RemoteMethodCall(games.strategy.engine.message.RemoteMethodCall) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) HubInvoke(games.strategy.engine.message.HubInvoke)

Example 24 with RemoteName

use of games.strategy.engine.message.RemoteName in project triplea by triplea-game.

the class Chat method shutdown.

/**
 * Stop receiving events from the messenger.
 */
public void shutdown() {
    messengers.getChannelMessenger().unregisterChannelSubscriber(chatChannelSubscribor, new RemoteName(chatChannelName, IChatChannel.class));
    if (messengers.getMessenger().isConnected()) {
        final RemoteName chatControllerName = ChatController.getChatControlerRemoteName(chatName);
        final IChatController controller = (IChatController) messengers.getRemoteMessenger().getRemote(chatControllerName);
        controller.leaveChat();
    }
}
Also used : RemoteName(games.strategy.engine.message.RemoteName)

Example 25 with RemoteName

use of games.strategy.engine.message.RemoteName in project triplea by triplea-game.

the class ModeratorController method getHostConnections.

@Override
public String getHostConnections(final INode node) {
    assertUserIsAdmin();
    if (serverMessenger.getServerNode().equals(node)) {
        throw new IllegalStateException("Cannot do this for server node");
    }
    final RemoteName remoteName = RemoteHostUtils.getRemoteHostUtilsName(node);
    final IRemoteHostUtils remoteHostUtils = (IRemoteHostUtils) allMessengers.getRemoteMessenger().getRemote(remoteName);
    return remoteHostUtils.getConnections();
}
Also used : RemoteName(games.strategy.engine.message.RemoteName)

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