use of io.joynr.proxy.ProxyBuilder in project joynr by bmwcarit.
the class JoynrAndroidExampleApplication method createProxy.
public void createProxy() {
if (runtime == null) {
logger.error("runtime has not been initialized!");
logToOutput("runtime has not been initialized!\n");
}
logToOutput("Creating joynr GPS proxy and requesting location...\n");
// 2 minutes ttl
MessagingQos messagingQos = new MessagingQos(2 * 60 * 1000);
DiscoveryQos discoveryQos = new // 30 second timeout to find a provider
DiscoveryQos(// 30 second timeout to find a provider
30 * 1000, ArbitrationStrategy.HighestPriority, Integer.MAX_VALUE, DiscoveryScope.LOCAL_ONLY);
try {
ProxyBuilder<GpsProxy> builder = runtime.getProxyBuilder(PROVIDER_DOMAIN, GpsProxy.class);
builder.setDiscoveryQos(discoveryQos).setMessagingQos(messagingQos).build(new ProxyBuilder.ProxyCreatedCallback<GpsProxy>() {
@Override
public void onProxyCreationFinished(GpsProxy newProxy) {
logToOutput("Proxy created");
proxy = newProxy;
}
@Override
public void onProxyCreationError(JoynrRuntimeException error) {
logToOutput("Error during proxy creation: " + error.getMessage() + "\n");
}
});
} catch (Exception e) {
logToOutput("ERROR: create proxy failed: " + e.getMessage() + "\n");
logger.error("create proxy failed: ", e);
}
}
Aggregations