Search in sources :

Example 1 with ProxyBuilder

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);
    }
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) GpsProxy(joynr.vehicle.GpsProxy) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) ProxyBuilder(io.joynr.proxy.ProxyBuilder)

Aggregations

DiscoveryQos (io.joynr.arbitration.DiscoveryQos)1 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 MessagingQos (io.joynr.messaging.MessagingQos)1 ProxyBuilder (io.joynr.proxy.ProxyBuilder)1 GpsProxy (joynr.vehicle.GpsProxy)1