Search in sources :

Example 1 with Client

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

the class POJOCallExamples method callResultSimplePOJO.

public static CompletableFuture<ExitInfo> callResultSimplePOJO(String wsAddress, String realm) {
    Session wampSession = new Session();
    wampSession.addOnJoinListener((session, details) -> {
        CompletableFuture<Person> callFuture = session.call("com.example.get_person", Person.class);
        callFuture.whenComplete((person, throwable) -> {
            System.out.println(String.format("Person: %s %s in department %s", person.firstname, person.lastname, person.department));
        });
    });
    Client wampClient = new Client(wampSession, wsAddress, realm);
    return wampClient.connect();
}
Also used : Client(io.crossbar.autobahn.wamp.Client) Person(io.crossbar.autobahn.demogallery.data.Person) Session(io.crossbar.autobahn.wamp.Session)

Example 2 with Client

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

the class POJORegisterExamples method registerSimplePOJO.

public static CompletableFuture<ExitInfo> registerSimplePOJO(String wsAddress, String realm) {
    Session wampSession = new Session();
    wampSession.addOnJoinListener((session, details) -> {
        CompletableFuture<Registration> regFuture = session.register("io.crossbar.example.get_person", POJORegisterExamples::get_person);
        regFuture.whenComplete((registration, throwable) -> {
            System.out.println(String.format("Registered procedure %s", registration.procedure));
        });
    });
    Client wampClient = new Client(wampSession, wsAddress, realm);
    return wampClient.connect();
}
Also used : Registration(io.crossbar.autobahn.wamp.types.Registration) Client(io.crossbar.autobahn.wamp.Client) Session(io.crossbar.autobahn.wamp.Session)

Example 3 with Client

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

the class POJORegisterExamples method registerListPOJOs.

public static CompletableFuture<ExitInfo> registerListPOJOs(String wsAddress, String realm) {
    Session wampSession = new Session();
    wampSession.addOnJoinListener((session, details) -> {
        CompletableFuture<Registration> regFuture = session.register("io.crossbar.example.get_person", POJORegisterExamples::get_persons);
        regFuture.whenComplete((registration, throwable) -> {
            System.out.println(String.format("Registered procedure %s", registration.procedure));
        });
    });
    Client wampClient = new Client(wampSession, wsAddress, realm);
    return wampClient.connect();
}
Also used : Registration(io.crossbar.autobahn.wamp.types.Registration) Client(io.crossbar.autobahn.wamp.Client) Session(io.crossbar.autobahn.wamp.Session)

Example 4 with Client

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

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

the class ExampleClient 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)

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