0

About service client in Windows 7 SDK 14.02 doesn't receive Announce signal

asked 2014-04-09 14:19:38 -0700

mattpho gravatar image

I am adding About interface to the basic_service cpp sample in the sdk, derive from AnnounceHandlerImpl class and override the Announce() method on the class but it's never called. Please let me know what I do wrong. Thank you Matt

Here is the server code:

int main()
{
   :
    status = s_bus->Start();
    status = ConnectBusAttachment();
    const TransportMask SERVICE_TRANSPORT_TYPE = TRANSPORT_ANY;
    status = CreateSession(SERVICE_TRANSPORT_TYPE);

    services::AboutPropertyStoreImpl aboutStore;
    aboutStore.setDeviceId("1231232145667745675477");
    aboutStore.setDeviceName("MyDeviceName");
    aboutStore.setAppId("000102030405060708090A0B0C0D0E0C");
    aboutStore.setAppName("AboutConfig");

    services::AboutService aboutService(*s_bus, aboutStore);
    status = aboutService.Register(0);
    // register about interface and about object
    std::vector<qcc::String> aboutIntf;
    aboutIntf.push_back("org.alljoyn.About");
    status = aboutService.AddObjectDescription("/About", aboutIntf);
    assert(ER_OK == status);
    status = s_bus->RegisterBusObject(aboutService);
    assert(ER_OK == status);
    status = aboutService.Announce();
    assert(ER_OK == status);

    /* Perform the service asynchronously until the user signals for an exit. */
    if (ER_OK == status) {
        WaitForSigInt();
    }
}

here is the client code:

class AnnounceHandlerImpl : public ajn::services::AnnounceHandler
{
public:
    void Announce(
        unsigned short version,
        unsigned short port,
        const char* busName,
        const ObjectDescriptions& objectDescs,
        const AboutData& aboutData)
    {
        printf("%u\n", version);
    }
};

int main()
{
        :
    status = s_bus->Start();
        status = ConnectBusAttachment();
    AnnounceHandlerImpl aboutHandler;
    status = services::AnnouncementRegistrar::RegisterAnnounceHandler(*s_bus, aboutHandler);
    assert(ER_OK == status);
    /* Perform the service asynchronously until the user signals for an exit. */
    if (ER_OK == status) {
        WaitForSigInt();
    }
}
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2014-04-09 18:11:58 -0700

georgen gravatar image

There is a bug in the current code that the signal will not be received till you call the following AddMatch rule

s_bus->AddMatch("sessionless='t',type='error'");

This is a work around for a known issue that should be fixed in the next release of AllJoyn.

Assumption the call ConnectBusAttachment() contains the call to BusAttachment::Connect() if Connect is not called you will not receive the Announce signal since you are not connected to the routing node.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2014-04-09 14:19:38 -0700

Seen: 328 times

Last updated: Apr 09 '14