use of org.nustaq.kontraktor.remoting.http.HttpConnectable in project kontraktor by RuedigerMoeller.
the class HelloClient method main.
public static void main(String[] args) {
org.nustaq.kontraktor.remoting.base.ConnectableActor[] connectables = { new WebSocketConnectable(HelloActor.class, "http://localhost:8080/hello").serType(SerializerType.FSTSer), new HttpConnectable(HelloActor.class, "http://localhost:8080/hellohttp").serType(SerializerType.JsonNoRefPretty), new TCPConnectable(HelloActor.class, "localhost", 6789) };
stream(connectables).forEach(connectable -> {
HelloActor remote = (HelloActor) connectable.connect((res, err) -> System.out.println(connectable + " disconnected !")).await();
remote.getMyName().then(name -> {
System.out.println(connectable.getClass().getSimpleName() + " " + name);
});
});
}
use of org.nustaq.kontraktor.remoting.http.HttpConnectable in project kontraktor by RuedigerMoeller.
the class MyJavaClient method main.
public static void main(String[] args) {
boolean http = false;
MyHttpApp remoteApp;
if (http) {
HttpClientConnector.DumpProtocol = true;
remoteApp = (MyHttpApp) new HttpConnectable(MyHttpApp.class, "http://localhost:8080/api").serType(SerializerType.JsonNoRefPretty).connect().await();
} else {
// dev only
JSR356ClientConnector.DumpProtocol = true;
remoteApp = (MyHttpApp) new WebSocketConnectable(MyHttpApp.class, "ws://localhost:8080/ws").serType(SerializerType.JsonNoRefPretty).connect().await();
}
MyHttpAppSession session = remoteApp.login("someuser", "apwd").await();
session.getToDo().then(list -> {
list.forEach(System.out::println);
});
session.streamToDo("p", (r, e) -> System.out.println(r + " " + e));
}
use of org.nustaq.kontraktor.remoting.http.HttpConnectable in project kontraktor by RuedigerMoeller.
the class KLoadTest method run.
public void run() {
boolean http = false;
ConnectableActor connectable;
if (!http) {
connectable = new WebSocketConnectable(MyHttpApp.class, "ws://localhost:8080/ws").serType(SerializerType.JsonNoRef);
} else {
connectable = new HttpConnectable(MyHttpApp.class, "http://localhost:8080/api").serType(SerializerType.JsonNoRef);
}
connectable.connect((connector, error) -> {
System.out.println("connection lost " + connector);
}).then((res, err) -> {
myApp = (MyHttpApp) res;
myApp.login("dummy", "dummy").then((s, err1) -> {
session = s;
System.out.println("session connected " + session);
session.subscribe((result, e) -> {
count++;
lastBcast.set(System.currentTimeMillis());
});
});
});
}
use of org.nustaq.kontraktor.remoting.http.HttpConnectable in project kontraktor by RuedigerMoeller.
the class TestCrashClose method main.
public static void main(String[] args) {
boolean http = false;
ConnectableActor connectable;
if (!http) {
connectable = new WebSocketConnectable(MyHttpApp.class, "ws://localhost:8080/ws").serType(SerializerType.JsonNoRef);
} else {
connectable = new HttpConnectable(MyHttpApp.class, "http://localhost:8080/api").serType(SerializerType.JsonNoRef);
}
connectable.connect((connector, error) -> {
System.out.println("connection lost " + connector);
}).then((res, err) -> {
MyHttpApp myApp = (MyHttpApp) res;
myApp.login("dummy", "dummy").then((s, err1) -> {
MyHttpAppSession session = s;
System.out.println("session connected " + session);
session.subscribe((result, e) -> {
System.exit(0);
});
});
});
}
use of org.nustaq.kontraktor.remoting.http.HttpConnectable in project kontraktor by RuedigerMoeller.
the class RemotingTest method testHttpMany.
@Test
public void testHttpMany() throws Exception {
checkSequenceErrors = false;
RemotingTestService service = Actors.AsActor(RemotingTestService.class, Q_SIZE);
ActorServer publisher = new HttpPublisher(service, "localhost", "/lp", 8082).publish().await();
RemotingTestService client = (RemotingTestService) new HttpConnectable(RemotingTestService.class, "http://localhost:8082/lp").connect().await(9999999);
ExecutorService exec = Executors.newCachedThreadPool();
CountDownLatch latch = new CountDownLatch(10);
for (int i = 0; i < 10; i++) {
exec.execute(() -> {
try {
runWithClient(client, latch);
} catch (Exception e) {
e.printStackTrace();
}
});
}
latch.await();
// wait for outstanding callbacks
Thread.sleep(2000);
publisher.close();
}
Aggregations