1

Where can I find the AboutClient Example for Java?

asked 2016-01-19 06:50:24 -0700

ajit.jain1 gravatar image

Hi Everyone,

i am currently working on a project to interact with a Windows Alljoyn UWP App and an Android App, since the Windows Alljoyn App uses the About Announcement feature(Producer/Service) , i am searching for an AboutClient example for the Android App which will act as the client.

I went through the About Api Guide for Java avialble at the below link, but it was not very clear to me.

https://allseenalliance.org/framework...

Any suggestion will be more than helpful.

Thanks and regards Ajit :)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-01-19 07:19:28 -0700

Hello,

There is a sample in the main SDK called JavaSDKDocAboutClient, it will work for Android.

You need to implement AboutListener, and to register on the Bus, once it is done the announced will be called, and you can create the different proxies.

public class SampleClass implements AboutListener{

...

    private void initializeBus() {

        try {
            String busName = UUID.randomUUID().toString();
            bus = new BusAttachment(busName, BusAttachment.RemoteMessage.Receive, 256);

            Status status = bus.connect();
            if (status != Status.OK) {
                return;
            }

            bus.registerAboutListener(this);

            status = bus.whoImplements(new String[]{"HERE THE PATH OF YOU WANT"});
            if (status != Status.OK) {
                return;
            }
        }
        catch(Exception ex){
                  ;
        }
    }

    @Override
    public void announced(String busName, int version, short port, AboutObjectDescription[] objectDescriptions,  Map<String, Variant> aboutData) {

        SessionOpts sessionOpts = new SessionOpts();
        sessionOpts.traffic = SessionOpts.TRAFFIC_MESSAGES;
        sessionOpts.isMultipoint = true;
        sessionOpts.proximity = SessionOpts.PROXIMITY_ANY;
        sessionOpts.transports = SessionOpts.TRANSPORT_ANY;

        Mutable.IntegerValue sessionId = new Mutable.IntegerValue();

        bus.enableConcurrentCallbacks();

        Status status = bus.joinSession(busName, port, sessionId, sessionOpts, new SessionListener());
        if (status != Status.OK) {
            return;
        }

        // HERE YOU CAN CREATE YOUR PROXY
        ProxyBusObject proxyObj = bus.getProxyBusObject(busName, PATH, sessionId.value, new Class<?>[]{
                LIST OF CLASSES });

        ....

    }
}

Thomas

edit flag offensive delete publish link more

Comments

Thanks for the help, will look up the code :)

ajit.jain1 ( 2016-01-19 07:21:59 -0700 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2016-01-19 06:50:24 -0700

Seen: 92 times

Last updated: Jan 19 '16