powered by Jive Software

How do i use the external IM gateway with Smack APIs

I am coding my own SMACK client but i wanted it to signin to the external gateway automatically so my msn friends could see that i am online. How can i do it?

This should happen automatically, as long as you’'re already registered.

I tried but i does not seems to work. When my own smack client log in and come online. The external Gateway page in wildfire recongnise it on line but the msn name appear as offline. I think my smack client may need to send some stuff to the wildfire server to turn it online. I coded my smack client from scratch.

The gateway has to be on the roster, so it gets notified of undirected presence updates.

Alternatively, you can send a directed presence to the gateway.

How could i send a presence packet to the gateway. As in the exact code to used

Presence ppacket = new Presence(Presence.Type.AVAILABLE);


Presence ppacket = new Presence(Presence.Type.UNAVAILABLE);

(that code is based on the old 2.2.1 API)

what am i suppose to put in (“aim.example.com”)? is it my msn id or other stuff. I will be connecting to MSN.

That’‘s the name of the gateway you’‘re using. Its name doesn’'t follow any pattern (the system administrator has to name it). You can get a list of gateways (and other services) of a server by sending a disco#items request.

ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = sdm.discoverItems("example.com");
Iterator itemsIterator = items.getItems(); while(itemsIterator.hasNext()) {
DiscoverItems.Item item = itemsIterator.next();
if(sdm.discoverInfo(item.getEntityID(), item.getNode()).containsFeature("jabber:iq:gateway")) {

This should output all gateways connected to the XMPP server example.com. (Note that this API is synchronous, so it should not be run in the same thread used by a user interface).

The code was written in this forum’'s web form, so it might not work 100%.

You can check the type of the gateway by iterating the identities in the object returned from the discoverInfo-method in the example above. It has to contain a identity with the category “gateway” and the type “msn”. (The full list of categories is available here.)

Thanks, It works