use of io.crossbar.autobahn.wamp.Session 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();
}
use of io.crossbar.autobahn.wamp.Session 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();
}
use of io.crossbar.autobahn.wamp.Session 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();
}
use of io.crossbar.autobahn.wamp.Session 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();
}
use of io.crossbar.autobahn.wamp.Session 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();
}
Aggregations