powered by Jive Software

Feature discovery for detecting client type


I’'m trying to detect the difference between mobile and PC-based clients. JEP-0030, supported by Wildfire, should allow this. How do I make use of service discovery in a server-side module to detect this difference?

Hey Frank,

You are in the right track by using Service Discovery to get the type of client the other party is using. However, the disco request should be sent to the client to get this identity rather than sending it to the server. Since service discovery uses IQ packets you will have to send the IQ disco request to the full JID of the user (not the bare JID). IQ packets whose TO is a fullJID (i.e. include the resource) are redirected to the target entity rather than being handled by the server.

Once the target entity received the disco request he should answer his identity. As defined in http://www.jabber.org/registrar/disco-categories.html#client mobile clients should return an identity of type “phone” and pc-based clients should return “pc”.

Hope that helps,


– Gato


Thank you for your answer. I was wondering about implementation-specifics, though. Smack provides a relatively simple mechanism of querying through existing classes and methods. This returns an object that can be queried for the relevant information.

It seems odd to me if the server is incapable of performing a similar action. From your answer I gather that I’'d have to create my own IQ packet with the appropriate namespace of type ‘‘get’’, filter for the response, then parse the XML manually? Basically my question is, can I be lazy and use prebuilt functionality (which I cannot find at the moment) or do I have to do this sort of thing myself?



Hey Frank,

I guess my response was not clear enough.

The server is not involved when discovering the type of another client. The server just needs to redirect the packet from client to client. Let me give you a Smack example of what you will have to do:

// Discover the identity of the other client. Note that the FULL JID MUST be passed as parameter. Full JID = bare JID + resource. In this case resource = Work

DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(myConnection).discoverInfo("john@myserver.com/Work");

// Check the identity of the client

Iterator identities = info.getIdentities();

DiscoverInfo.Identity identity = (DiscoverInfo.Identity)identities.next();

if (“pc”.equals(identity.getType())) {

System.out.println(“The other client is of type: Standard full-GUI client used on desktops and laptops”);


else if (“phone”.equals(identity.getType())) {

System.out.println(“The other client is of type: A client running on a mobile phone or other telephony device”);


else {

System.out.println("The other client is of type: " + identity.getType());



Hope that helps.


– Gato

Again, helpful, but not quite what I was looking for. I have a plugin for Wildfire that has to take a certain course of action dependant on whether we’‘re talking to a mobile device or a PC-based device. My thinking was that the client doesn’‘t need to know what the other side’‘s client type is, as it’'s not relevant for the actual communications being sent, just for the client-to-server path.

I’‘m now thinking of letting the initiating client work out what the heck the other side is, and simply informing the server of client-type through an IQ packet we’'re already using anyway.

My next question would then be “How do I make it work in Smack?”, for which I’‘d open up a can of Documentation, but you’'ve just answered that part. Thanks.