Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 1 | package org.onlab.netty; |
| 2 | |
| 3 | import java.util.concurrent.TimeUnit; |
| 4 | |
| 5 | public final class SimpleClient { |
| 6 | private SimpleClient() {} |
| 7 | |
| 8 | public static void main(String... args) throws Exception { |
| 9 | NettyMessagingService messaging = new TestNettyMessagingService(9081); |
| 10 | messaging.activate(); |
| 11 | |
| 12 | messaging.sendAsync(new Endpoint("localhost", 8080), "simple", "Hello World"); |
| 13 | Response<String> response = messaging.sendAndReceive(new Endpoint("localhost", 8080), "echo", "Hello World"); |
| 14 | System.out.println("Got back:" + response.get(2, TimeUnit.SECONDS)); |
| 15 | } |
| 16 | |
| 17 | public static class TestNettyMessagingService extends NettyMessagingService { |
| 18 | public TestNettyMessagingService(int port) throws Exception { |
| 19 | super(port); |
| 20 | Serializer serializer = new KryoSerializer(); |
| 21 | this.serializer = serializer; |
| 22 | } |
| 23 | } |
| 24 | } |