Search in sources :

Example 6 with Client

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

the class POJOCallExamples method callResultListPOJOs.

public static CompletableFuture<ExitInfo> callResultListPOJOs(String wsAddress, String realm) {
    Session wampSession = new Session();
    wampSession.addOnJoinListener((session, details) -> {
        CompletableFuture<List<Person>> callFuture = session.call("com.example.get_all_persons", new TypeReference<List<Person>>() {
        });
        callFuture.whenComplete((persons, throwable) -> {
            System.out.println(String.format("Got %s persons", persons.size()));
            for (Person p : persons) {
                System.out.println(String.format("Person: %s %s in department %s", p.firstname, p.lastname, p.department));
            }
        });
    });
    Client wampClient = new Client(wampSession, wsAddress, realm);
    return wampClient.connect();
}
Also used : List(java.util.List) Client(io.crossbar.autobahn.wamp.Client) Person(io.crossbar.autobahn.demogallery.data.Person) Session(io.crossbar.autobahn.wamp.Session)

Example 7 with Client

use of io.crossbar.autobahn.wamp.Client 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)

Example 8 with Client

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

the class AuthenticationExampleClient method connect.

private static CompletableFuture<ExitInfo> connect(String websocketURL, String realm, IAuthenticator authenticator) {
    Session wampSession = new Session();
    wampSession.addOnJoinListener((session, details) -> System.out.println("Joined session."));
    Client client = new Client(wampSession, websocketURL, realm, authenticator);
    return client.connect();
}
Also used : Client(io.crossbar.autobahn.wamp.Client) Session(io.crossbar.autobahn.wamp.Session)

Example 9 with Client

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

the class ReflectionHelloClient method main.

public CompletableFuture<ExitInfo> main(String websocketURL, String realm) {
    Session session = new Session();
    session.addOnConnectListener(this::onConnectCallback);
    session.addOnJoinListener(this::onJoinCallback);
    session.addOnLeaveListener(this::onLeaveCallback);
    session.addOnDisconnectListener(this::onDisconnectCallback);
    // finally, provide everything to a Client instance and connect
    Client client = new Client(session, websocketURL, realm);
    return client.connect();
}
Also used : Client(io.crossbar.autobahn.wamp.Client) Session(io.crossbar.autobahn.wamp.Session)

Example 10 with Client

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

the class ReflectionPOJOCallSample method callReflectionPOJOResult.

public static CompletableFuture<ExitInfo> callReflectionPOJOResult(String wsAddress, String realm) {
    Session wampSession = new Session();
    wampSession.addOnJoinListener((session, details) -> {
        IPOJOServiceProxy proxy = session.getReflectionServices().getCalleeProxy(IPOJOServiceProxy.class);
        CompletableFuture<Person> personFuture = proxy.getPersonAsync();
        personFuture.whenComplete((person, throwable) -> {
            System.out.println(String.format("Person: %s %s in department %s", person.firstname, person.lastname, person.department));
        });
        CompletableFuture<List<Person>> peopleFuture = proxy.getPeopleAsync();
        peopleFuture.whenComplete((persons, throwable) -> {
            System.out.println(String.format("Got %s persons", persons.size()));
            for (Person p : persons) {
                System.out.println(String.format("Person: %s %s in department %s", p.firstname, p.lastname, p.department));
            }
        });
    });
    Client wampClient = new Client(wampSession, wsAddress, realm);
    return wampClient.connect();
}
Also used : List(java.util.List) Client(io.crossbar.autobahn.wamp.Client) Person(io.crossbar.autobahn.demogallery.data.Person) Session(io.crossbar.autobahn.wamp.Session)

Aggregations

Client (io.crossbar.autobahn.wamp.Client)11 Session (io.crossbar.autobahn.wamp.Session)9 Person (io.crossbar.autobahn.demogallery.data.Person)4 Registration (io.crossbar.autobahn.wamp.types.Registration)3 ExitInfo (io.crossbar.autobahn.wamp.types.ExitInfo)2 List (java.util.List)2 ArrayList (java.util.ArrayList)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1