Search code examples
c#windows-10windows-10-universalalljoynwindowsiot

AllJoyn Studio - Multiple Interface Implementation


I am trying to implement an AllJoyn consumer with multiple interfaces. The AllJoyn menu creates the helper files for all the interfaces from the introspection xml. After Adding the watcher event handler and starting the same for all the interfaces only the first watcher event handler is fired and completed.

for example in the LSF introspection we have four interfaces hence:

AllJoynBusAttachment bus_Consumer = new AlljoynBusAttachment();

watcher_Consumer = new LampStateWatcher(bus_Consumer);
watcher_Consumer.Added += Watcher_Consumer_Added;
watcher_Consumer.Start();

watcher_Details = new LampDetailsWatcher(bus_Consumer);
watcher_Details.Added += Watcher_Details_Added;
watcher_Details.Start();


private async void Watcher_Details_Added(LampDetailsWatcher sender, AllJoynServiceInfo args)
        {
            Join_Session_Details = await LampDetailsConsumer.JoinSessionAsync(args, sender);
                Consumer_Details = Join_Session_Details.Consumer;

                if (Join_Session_Details.Status == AllJoynStatus.Ok)
                {
                    var LampName = await Consumer_Details.GetLampIDAsync();
                    Status_List.Items.Add(LampName.LampID);
                }
         }


 private async void Watcher_Consumer_Added(LampStateWatcher sender, AllJoynServiceInfo args)
        {
            Join_Session = await LampStateConsumer.JoinSessionAsync(args, sender);
                Consumer_Bulb = Join_Session.Consumer;
            if (Join_Session.Status == AllJoynStatus.Ok)
            {
                LightBulbs.Add(Consumer_Bulb);
            }

            Consumer_Bulb.SessionMemberRemoved += Consumer_Bulb_SessionMemberRemoved;
    }

In this case only the Watcher_Consumer_Added is fired and completed where as the the Watcher_Details_Added is fired but not completed.

How can I complete both the processes. Is the above method correct to implement multiple interfaces on the consumer?

P.S. : this is using the AllJoyn Studio extension for VS2015 running on Windows10


Solution

  • An additional BusAttachement is required for the second watcher. A single bus cannot be shared between two watchers. This is the answer i received on MSDN forum.

    The link to the same is here AllJoyn Studio - Multiple Interface Implementation