Search in sources :

Example 1 with RemoteMethodCall

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

the class ServerMessenger method bareBonesSendChatMessage.

private void bareBonesSendChatMessage(final String message, final INode to) {
    final RemoteName rn = new RemoteName(isLobby() ? ChatController.getChatChannelName("_LOBBY_CHAT") : ChatController.getChatChannelName("games.strategy.engine.framework.ui.ServerStartup.CHAT_NAME"), IChatChannel.class);
    final RemoteMethodCall call = new RemoteMethodCall(rn.getName(), "chatOccured", new Object[] { message }, new Class<?>[] { String.class }, IChatChannel.class);
    final SpokeInvoke spokeInvoke = new SpokeInvoke(null, false, call, getServerNode());
    send(spokeInvoke, to);
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) RemoteMethodCall(games.strategy.engine.message.RemoteMethodCall) SpokeInvoke(games.strategy.engine.message.SpokeInvoke)

Example 2 with RemoteMethodCall

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

the class EndPointTest method testEndPoint.

@Test
public void testEndPoint() {
    final EndPoint endPoint = new EndPoint("", Comparator.class, false);
    endPoint.addImplementor((Comparator<Object>) (o1, o2) -> 2);
    final RemoteMethodCall call = new RemoteMethodCall("", "compare", new Object[] { "", "" }, new Class<?>[] { Object.class, Object.class }, Comparator.class);
    final List<RemoteMethodCallResults> results = endPoint.invokeLocal(call, endPoint.takeANumber(), null);
    assertEquals(1, results.size());
    assertEquals(2, (results.iterator().next()).getRVal());
}
Also used : Test(org.junit.jupiter.api.Test) RemoteMethodCall(games.strategy.engine.message.RemoteMethodCall) List(java.util.List) RemoteMethodCallResults(games.strategy.engine.message.RemoteMethodCallResults) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Comparator(java.util.Comparator) RemoteMethodCall(games.strategy.engine.message.RemoteMethodCall) RemoteMethodCallResults(games.strategy.engine.message.RemoteMethodCallResults) Test(org.junit.jupiter.api.Test)

Example 3 with RemoteMethodCall

use of games.strategy.engine.message.RemoteMethodCall 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 4 with RemoteMethodCall

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

the class Invoke method readExternal.

@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    needReturnValues = in.read() == 1;
    if (needReturnValues) {
        methodCallId = (GUID) in.readObject();
    }
    call = new RemoteMethodCall();
    call.readExternal(in);
}
Also used : RemoteMethodCall(games.strategy.engine.message.RemoteMethodCall)

Aggregations

RemoteMethodCall (games.strategy.engine.message.RemoteMethodCall)4 RemoteName (games.strategy.engine.message.RemoteName)2 HubInvoke (games.strategy.engine.message.HubInvoke)1 RemoteMethodCallResults (games.strategy.engine.message.RemoteMethodCallResults)1 SpokeInvoke (games.strategy.engine.message.SpokeInvoke)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Test (org.junit.jupiter.api.Test)1