use of org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable in project kontraktor by RuedigerMoeller.
the class BrowseriBabelify method get.
public static BrowseriBabelify get() {
synchronized (BrowseriBabelify.class) {
if (singleton == null) {
WebSocketConnectable webSocketConnectable = new WebSocketConnectable(BrowseriBabelify.class, url).coding(new Coding(SerializerType.JsonNoRef, BabelResult.class, BabelOpts.class));
singleton = (BrowseriBabelify) webSocketConnectable.connect((xy, e) -> System.out.println("disconnected " + xy)).await(1000);
}
}
return singleton;
}
use of org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable 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.websockets.WebSocketConnectable 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.websockets.WebSocketConnectable in project kontraktor by RuedigerMoeller.
the class DummyServiceKrouterClient method main.
public static void main(String[] args) {
// connect to service via Krouter
DummyService routerClient = (DummyService) Routing.connectClient(new WebSocketConnectable().url("ws://localhost:8888/binary").actorClass(DummyService.class).serType(SerializerType.FSTSer), x -> System.exit(1)).await();
try {
// throws exception if not available
routerClient.ping().await();
} catch (AwaitException ae) {
ae.printStackTrace();
System.exit(1);
}
runTest(routerClient);
}
use of org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable in project kontraktor by RuedigerMoeller.
the class DummyService method main.
public static void main(String[] args) {
DummyService serv = Actors.AsActor(DummyService.class);
serv.init();
Krouter krouter = (Krouter) Routing.registerService(new WebSocketConnectable().url("ws://localhost:8888/binary").actorClass(Krouter.class).serType(SerializerType.FSTSer), serv, x -> {
System.out.println("discon " + x);
System.exit(-1);
}, true).await();
Log.Info(DummyService.class, "service registered at krouter");
}
Aggregations