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