Search in sources :

Example 1 with ExitInfo

use of io.crossbar.autobahn.wamp.types.ExitInfo in project autobahn-java by crossbario.

the class Service method start.

public int start(String url, String realm) {
    LOGGER.info(String.format("Called with url=%s, realm=%s", url, realm));
    // finally, provide everything to a Client instance
    Client client = new Client(mSession, url, realm, mExecutor);
    CompletableFuture<ExitInfo> exitFuture = client.connect();
    try {
        ExitInfo exitInfo = exitFuture.get();
        return exitInfo.code;
    } catch (Exception e) {
        LOGGER.severe(e.getMessage());
        return 1;
    }
}
Also used : ExitInfo(io.crossbar.autobahn.wamp.types.ExitInfo) Client(io.crossbar.autobahn.wamp.Client)

Example 2 with ExitInfo

use of io.crossbar.autobahn.wamp.types.ExitInfo in project autobahn-java by crossbario.

the class Client method connect.

public CompletableFuture<ExitInfo> connect(TransportOptions options) {
    CompletableFuture<ExitInfo> exitFuture = new CompletableFuture<>();
    mSession.addOnConnectListener((session) -> mSession.join(mRealm, mAuthenticators).thenAccept(details -> LOGGER.i(String.format("JOINED session=%s realm=%s", details.sessionID, details.realm))));
    mSession.addOnDisconnectListener((session, wasClean) -> exitFuture.complete(new ExitInfo(wasClean)));
    CompletableFuture.runAsync(() -> {
        try {
            mTransports.get(0).connect(mSession, options);
        } catch (Exception e) {
            throw new CompletionException(e);
        }
    }, getExecutor());
    return exitFuture;
}
Also used : List(java.util.List) Executor(java.util.concurrent.Executor) ITransport(io.crossbar.autobahn.wamp.interfaces.ITransport) IABLogger(io.crossbar.autobahn.utils.IABLogger) CompletableFuture(java.util.concurrent.CompletableFuture) CompletionException(java.util.concurrent.CompletionException) TransportOptions(io.crossbar.autobahn.wamp.types.TransportOptions) Platform(io.crossbar.autobahn.wamp.utils.Platform) ABLogger(io.crossbar.autobahn.utils.ABLogger) ArrayList(java.util.ArrayList) IAuthenticator(io.crossbar.autobahn.wamp.interfaces.IAuthenticator) ExitInfo(io.crossbar.autobahn.wamp.types.ExitInfo) CompletableFuture(java.util.concurrent.CompletableFuture) ExitInfo(io.crossbar.autobahn.wamp.types.ExitInfo) CompletionException(java.util.concurrent.CompletionException) CompletionException(java.util.concurrent.CompletionException)

Example 3 with ExitInfo

use of io.crossbar.autobahn.wamp.types.ExitInfo in project autobahn-java by crossbario.

the class CIService method start.

public int start(String url, String realm) {
    LOGGER.i(String.format("Called with url=%s, realm=%s", url, realm));
    // finally, provide everything to a Client instance
    Client client = new Client(mSession, url, realm, mExecutor);
    CompletableFuture<ExitInfo> exitFuture = client.connect();
    try {
        ExitInfo exitInfo = exitFuture.get();
        return exitInfo.code;
    } catch (Exception e) {
        LOGGER.e(e.getMessage());
        return 1;
    }
}
Also used : ExitInfo(io.crossbar.autobahn.wamp.types.ExitInfo) Client(io.crossbar.autobahn.wamp.Client) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ExitInfo (io.crossbar.autobahn.wamp.types.ExitInfo)3 Client (io.crossbar.autobahn.wamp.Client)2 ABLogger (io.crossbar.autobahn.utils.ABLogger)1 IABLogger (io.crossbar.autobahn.utils.IABLogger)1 IAuthenticator (io.crossbar.autobahn.wamp.interfaces.IAuthenticator)1 ITransport (io.crossbar.autobahn.wamp.interfaces.ITransport)1 TransportOptions (io.crossbar.autobahn.wamp.types.TransportOptions)1 Platform (io.crossbar.autobahn.wamp.utils.Platform)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletionException (java.util.concurrent.CompletionException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Executor (java.util.concurrent.Executor)1