blob: 1573780eb3ddb310ad1da3b8486fa40013c6b831 [file] [log] [blame]
Madan Jampaniab6d3112014-10-02 16:30:14 -07001package org.onlab.netty;
2
3import java.util.concurrent.TimeUnit;
4
5public 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}