0

Is there any way in AllJoyn for Android through which I can get the number of devices across a Wi-Fi router that are using my app?

androidnoob
  • 345
  • 2
  • 17

2 Answers2

0

If your app uses the About feature, then on your monitor app you have to count the number of about announcement received, filtered by additional about field that identifies your app and not other Alljoyn devices.

Lino
  • 5,084
  • 3
  • 21
  • 39
0

Depends on how your app is being used. This question is a little ambiguous, since "devices using my app" could mean your app running within other folks devices (they are using your app by having installed it), or could mean your app is providing a service that other devices in the wifi network are connecting to (they are using your app by connecting to it as a remote client).

I assume you mean the second.

In your service app, when you bind the session port you can specify a SessionPortListener. Implement its sessionJoined() method to track the remote peers that join and leave a session with your app.

mBus.bindSessionPort(contactPort, sessionOpts, new SessionPortListener() {
    @Override   
    public boolean acceptSessionJoiner(short sessionPort, String joiner, SessionOpts sessionOpts) {
        return true;         
    }
    @Override          
    public void sessionJoined(short sessionPort, int id, final String joiner) {
        mPeers.add(joiner);
        mBus.setSessionListener(id, new SessionListener() {
            @Override
            public void sessionLost(int sessionId, int reason) {
                mPeers.remove(joiner);
            }           
        });         
    }           
});         
P. Sigurdson
  • 151
  • 4