Search in sources :

Example 6 with Person

use of io.crossbar.autobahn.demogallery.data.Person in project autobahn-java by crossbario.

the class ReflectionPOJORegisterSample method registerReflectionPOJO.

public static CompletableFuture<ExitInfo> registerReflectionPOJO(String wsAddress, String realm) {
    Session wampSession = new Session();
    wampSession.addOnJoinListener((session, details) -> {
        final IPOJOService service = new IPOJOService() {

            @Override
            public Person getPerson() {
                return new Person("john", "doe", "hr");
            }

            @Override
            public List<Person> getPeople() {
                List<Person> persons = new ArrayList<>();
                for (int i = 0; i < 7; i++) {
                    persons.add(new Person("john", "doe", "hr"));
                }
                return persons;
            }
        };
        List<CompletableFuture<Registration>> registrations = session.getReflectionServices().registerCallee(service);
        for (CompletableFuture<Registration> registrationCompletableFuture : registrations) {
            registrationCompletableFuture.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 : CompletableFuture(java.util.concurrent.CompletableFuture) Registration(io.crossbar.autobahn.wamp.types.Registration) ArrayList(java.util.ArrayList) Client(io.crossbar.autobahn.wamp.Client) Person(io.crossbar.autobahn.demogallery.data.Person) Session(io.crossbar.autobahn.wamp.Session)

Aggregations

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