Search in sources :

Example 1 with RemoteName

use of games.strategy.engine.message.RemoteName 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 RemoteName

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

the class ChannelMessengerTest method testMultipleClients.

@Test
public void testMultipleClients() throws Exception {
    // set up the client and server
    // so that the client has 1 subscribor, and the server knows about it
    final RemoteName test = new RemoteName(IChannelBase.class, "test");
    final ChannelSubscribor client1Subscribor = new ChannelSubscribor();
    clientChannelMessenger.registerChannelSubscriber(client1Subscribor, test);
    assertHasChannel(test, unifiedMessengerHub);
    assertEquals(1, clientChannelMessenger.getUnifiedMessenger().getLocalEndPointCount(test));
    // add a new client
    final String mac = MacFinder.getHashedMacAddress();
    final ClientMessenger clientMessenger2 = new ClientMessenger("localhost", serverPort, "client2", mac);
    final ChannelMessenger client2 = new ChannelMessenger(new UnifiedMessenger(clientMessenger2));
    ((IChannelBase) client2.getChannelBroadcastor(test)).testString("a");
    assertCallCountIs(client1Subscribor, 1);
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) IChannelSubscribor(games.strategy.engine.message.IChannelSubscribor) ChannelMessenger(games.strategy.engine.message.ChannelMessenger) ClientMessenger(games.strategy.net.ClientMessenger) Test(org.junit.jupiter.api.Test)

Example 3 with RemoteName

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

the class ChannelMessengerTest method testRemoteCall.

@Test
public void testRemoteCall() {
    final RemoteName testRemote = new RemoteName(IChannelBase.class, "testRemote");
    final ChannelSubscribor subscribor1 = new ChannelSubscribor();
    serverChannelMessenger.registerChannelSubscriber(subscribor1, testRemote);
    assertHasChannel(testRemote, unifiedMessengerHub);
    final IChannelBase channelTest = (IChannelBase) clientChannelMessenger.getChannelBroadcastor(testRemote);
    channelTest.testNoParams();
    assertCallCountIs(subscribor1, 1);
    channelTest.testString("a");
    assertCallCountIs(subscribor1, 2);
    channelTest.testPrimitives(1, (short) 0, 1, (byte) 1, true, (float) 1.0);
    assertCallCountIs(subscribor1, 3);
    channelTest.testArray(null, null, null, null, null, null);
    assertCallCountIs(subscribor1, 4);
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) IChannelSubscribor(games.strategy.engine.message.IChannelSubscribor) Test(org.junit.jupiter.api.Test)

Example 4 with RemoteName

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

the class RemoteMessengerTest method testVoidMethodCall.

@Test
public void testVoidMethodCall() {
    final TestRemote testRemote = new TestRemote();
    final RemoteName test = new RemoteName(ITestRemote.class, "test");
    remoteMessenger.registerRemote(testRemote, test);
    final ITestRemote remote = (ITestRemote) remoteMessenger.getRemote(test);
    remote.testVoid();
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) Test(org.junit.jupiter.api.Test)

Example 5 with RemoteName

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

the class RemoteMessengerTest method testMethodCall.

@Test
public void testMethodCall() {
    final TestRemote testRemote = new TestRemote();
    final RemoteName test = new RemoteName(ITestRemote.class, "test");
    remoteMessenger.registerRemote(testRemote, test);
    final ITestRemote remote = (ITestRemote) remoteMessenger.getRemote(test);
    assertEquals(2, remote.increment(1));
    assertEquals(testRemote.getLastSenderNode(), serverMessenger.getLocalNode());
}
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