Search in sources :

Example 1 with GUID

use of games.strategy.net.GUID in project triplea by triplea-game.

the class UnifiedMessenger method invokeAndWaitRemote.

private RemoteMethodCallResults invokeAndWaitRemote(final RemoteMethodCall remoteCall) {
    final GUID methodCallId = new GUID();
    final CountDownLatch latch = new CountDownLatch(1);
    synchronized (pendingLock) {
        pendingInvocations.put(methodCallId, latch);
    }
    // invoke remotely
    final Invoke invoke = new HubInvoke(methodCallId, true, remoteCall);
    send(invoke, messenger.getServerNode());
    Interruptibles.await(latch);
    synchronized (pendingLock) {
        final RemoteMethodCallResults methodCallResults = results.remove(methodCallId);
        if (methodCallResults == null) {
            throw new IllegalStateException("No results from remote call. Method returned:" + remoteCall.getMethodName() + " for remote name:" + remoteCall.getRemoteName() + " with id:" + methodCallId);
        }
        return methodCallResults;
    }
}
Also used : RemoteMethodCallResults(games.strategy.engine.message.RemoteMethodCallResults) GUID(games.strategy.net.GUID) CountDownLatch(java.util.concurrent.CountDownLatch) SpokeInvoke(games.strategy.engine.message.SpokeInvoke) HubInvoke(games.strategy.engine.message.HubInvoke) HubInvoke(games.strategy.engine.message.HubInvoke)

Example 2 with GUID

use of games.strategy.net.GUID in project triplea by triplea-game.

the class UnifiedMessengerHub method results.

private void results(final HubInvocationResults results, final INode from) {
    final GUID methodId = results.methodCallId;
    final InvocationInProgress invocationInProgress = invocations.get(methodId);
    final boolean done = invocationInProgress.process(results, from);
    if (done) {
        invocations.remove(methodId);
        if (invocationInProgress.shouldSendResults()) {
            sendResultsToCaller(methodId, invocationInProgress);
        }
    }
}
Also used : GUID(games.strategy.net.GUID)

Example 3 with GUID

use of games.strategy.net.GUID in project triplea by triplea-game.

the class LobbyGameTableModelTest method removeGameThatDoesNotExistIsIgnored.

@Test
public void removeGameThatDoesNotExistIsIgnored() {
    testObj.getLobbyGameBroadcaster().gameRemoved(new GUID());
    TestUtil.waitForSwingThreads();
    assertThat(testObj.getRowCount(), is(1));
}
Also used : GUID(games.strategy.net.GUID) Test(org.junit.jupiter.api.Test)

Example 4 with GUID

use of games.strategy.net.GUID in project triplea by triplea-game.

the class LobbyGameTableModelTest method updateGameAddsIfDoesNotExist.

@Test
public void updateGameAddsIfDoesNotExist() {
    testObj.getLobbyGameBroadcaster().gameUpdated(new GUID(), new GameDescription());
    TestUtil.waitForSwingThreads();
    assertThat(testObj.getRowCount(), is(2));
}
Also used : GUID(games.strategy.net.GUID) GameDescription(games.strategy.engine.lobby.server.GameDescription) Test(org.junit.jupiter.api.Test)

Example 5 with GUID

use of games.strategy.net.GUID in project triplea by triplea-game.

the class PlayerOwnerChange method perform.

@Override
protected void perform(final GameData data) {
    for (final GUID id : m_new.keySet()) {
        final Unit unit = data.getUnits().get(id);
        if (!m_old.get(id).equals(unit.getOwner().getName())) {
            throw new IllegalStateException("Wrong owner, expecting" + m_old.get(id) + " but got " + unit.getOwner());
        }
        final String owner = m_new.get(id);
        final PlayerID player = data.getPlayerList().getPlayerId(owner);
        unit.setOwner(player);
    }
    data.getMap().getTerritory(m_location).notifyChanged();
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) GUID(games.strategy.net.GUID) Unit(games.strategy.engine.data.Unit)

Aggregations

GUID (games.strategy.net.GUID)12 RemoteMethodCallResults (games.strategy.engine.message.RemoteMethodCallResults)4 PlayerID (games.strategy.engine.data.PlayerID)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 SpokeInvoke (games.strategy.engine.message.SpokeInvoke)2 Test (org.junit.jupiter.api.Test)2 Unit (games.strategy.engine.data.Unit)1 GameDescription (games.strategy.engine.lobby.server.GameDescription)1 ConnectionLostException (games.strategy.engine.message.ConnectionLostException)1 HubInvocationResults (games.strategy.engine.message.HubInvocationResults)1 HubInvoke (games.strategy.engine.message.HubInvoke)1 RemoteNotFoundException (games.strategy.engine.message.RemoteNotFoundException)1 SpokeInvocationResults (games.strategy.engine.message.SpokeInvocationResults)1 ArrayList (java.util.ArrayList)1