Search in sources :

Example 1 with ActorClient

use of org.nustaq.kontraktor.remoting.base.ActorClient in project kontraktor by RuedigerMoeller.

the class WebSocketConnectable method connect.

@Override
public <T extends Actor> IPromise<T> connect(Callback<ActorClientConnector> disconnectCallback, Consumer<Actor> actorDisconnecCB) {
    if (actorClass == null) {
        throw new RuntimeException("pls specify actor clazz to connect to");
    }
    Promise result = new Promise();
    Runnable connect = () -> {
        JSR356ClientConnector client = null;
        try {
            client = new JSR356ClientConnector(url);
            ActorClient connector = new ActorClient(client, actorClass, coding);
            connector.connect(inboundQueueSize, actorDisconnecCB).then(result);
        } catch (URISyntaxException e) {
            e.printStackTrace();
            result.reject(e);
        }
    };
    if (!Actor.inside()) {
        JSR356ClientConnector.get().execute(() -> Thread.currentThread().setName("JSR356WS singleton remote client actor polling"));
        JSR356ClientConnector.get().execute(connect);
    } else
        connect.run();
    return result;
}
Also used : IPromise(org.nustaq.kontraktor.IPromise) Promise(org.nustaq.kontraktor.Promise) ActorClient(org.nustaq.kontraktor.remoting.base.ActorClient) URISyntaxException(java.net.URISyntaxException)

Example 2 with ActorClient

use of org.nustaq.kontraktor.remoting.base.ActorClient in project kontraktor by RuedigerMoeller.

the class TCPConnectable method connect.

@Override
public <T extends Actor> IPromise<T> connect(Callback<ActorClientConnector> disconnectCallback, Consumer<Actor> actorDisconnecCB) {
    Promise result = new Promise();
    Runnable connect = () -> {
        TCPClientConnector client = new TCPClientConnector(port, host, disconnectCallback);
        ActorClient connector = new ActorClient(client, actorClz, coding);
        connector.connect(inboundQueueSize, actorDisconnecCB).then(result);
    };
    if (!Actor.inside()) {
        TCPClientConnector.get().execute(() -> Thread.currentThread().setName("tcp singleton remote client actor polling"));
        TCPClientConnector.get().execute(connect);
    } else
        connect.run();
    return result;
}
Also used : IPromise(org.nustaq.kontraktor.IPromise) Promise(org.nustaq.kontraktor.Promise) ActorClient(org.nustaq.kontraktor.remoting.base.ActorClient)

Example 3 with ActorClient

use of org.nustaq.kontraktor.remoting.base.ActorClient in project kontraktor by RuedigerMoeller.

the class HttpConnectable method connect.

@Override
public <T extends Actor> IPromise<T> connect(Callback<ActorClientConnector> disconnectCallback, Consumer<Actor> actorDisconnecCB) {
    HttpClientConnector con = new HttpClientConnector(this);
    con.disconnectCallback = disconnectCallback;
    ActorClient actorClient = new ActorClient(con, actorClz, coding);
    Promise p = new Promise();
    con.getRefPollActor().execute(() -> {
        Thread.currentThread().setName("Http Ref Polling");
        actorClient.connect(inboundQueueSize, null).then(p);
    });
    return p;
}
Also used : IPromise(org.nustaq.kontraktor.IPromise) Promise(org.nustaq.kontraktor.Promise) ActorClient(org.nustaq.kontraktor.remoting.base.ActorClient)

Aggregations

IPromise (org.nustaq.kontraktor.IPromise)3 Promise (org.nustaq.kontraktor.Promise)3 ActorClient (org.nustaq.kontraktor.remoting.base.ActorClient)3 URISyntaxException (java.net.URISyntaxException)1