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);
}
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);
}
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);
}
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();
}
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());
}
Aggregations