Search in sources :

Example 1 with WebSocketConnectable

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;
}
Also used : IPromise(org.nustaq.kontraktor.IPromise) SerializerType(org.nustaq.kontraktor.remoting.encoding.SerializerType) CallerSideMethod(org.nustaq.kontraktor.annotations.CallerSideMethod) Actor(org.nustaq.kontraktor.Actor) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable) Local(org.nustaq.kontraktor.annotations.Local) File(java.io.File) Coding(org.nustaq.kontraktor.remoting.encoding.Coding) Coding(org.nustaq.kontraktor.remoting.encoding.Coding) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)

Example 2 with WebSocketConnectable

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);
        });
    });
}
Also used : HttpConnectable(org.nustaq.kontraktor.remoting.http.HttpConnectable) TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)

Example 3 with WebSocketConnectable

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));
}
Also used : HttpConnectable(org.nustaq.kontraktor.remoting.http.HttpConnectable) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)

Example 4 with WebSocketConnectable

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);
}
Also used : DummyService(kontraktor.krouter.service.DummyService) AwaitException(org.nustaq.kontraktor.AwaitException) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)

Example 5 with WebSocketConnectable

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");
}
Also used : Krouter(org.nustaq.kontraktor.routers.Krouter) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)

Aggregations

WebSocketConnectable (org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)25 Test (org.junit.Test)10 WebSocketPublisher (org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 RateMeasure (org.nustaq.kontraktor.util.RateMeasure)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 SerializerType (org.nustaq.kontraktor.remoting.encoding.SerializerType)6 Log (org.nustaq.kontraktor.util.Log)6 Assert (org.junit.Assert)5 Ignore (org.junit.Ignore)5 Actor (org.nustaq.kontraktor.Actor)5 Actors (org.nustaq.kontraktor.Actors)5 KxPublisher (org.nustaq.kontraktor.reactivestreams.KxPublisher)5 KxReactiveStreams (org.nustaq.kontraktor.reactivestreams.KxReactiveStreams)5 HttpConnectable (org.nustaq.kontraktor.remoting.http.HttpConnectable)5 Publisher (org.reactivestreams.Publisher)5 RxReactiveStreams (rx.RxReactiveStreams)5 ActorSystem (akka.actor.ActorSystem)4 ActorMaterializer (akka.stream.ActorMaterializer)4 ActorMaterializerSettings (akka.stream.ActorMaterializerSettings)4