powered by Jive Software

Continuous connection

Hi,

I am new to Smack and just want to make sure that I am not missing something. After I have opened a connection to a Jabber server and registered my listeners

XMPPConnection conn = new XMPPConnection(“http://some.server”);

conn.addPacketListener(myListener, myFilter);

Do I really have to keep a while loop going to process packets:

while (conn.isConnected()) {}

or is there some method to put the client into a general waiting mode?

Cheers,

Matthew

Hi Matthew,

Do I really have to keep a while loop going to

process packets:

while (conn.isConnected()) {}

No, you don’‘t. You see this a lot in command line sample applications to prevent the application from exiting. A more typical situation would to have the application have some sort of “listener” that closes the connection and shutdowns the application when called. It’‘s not the best example but url=http://jivesoftware.org/community/thread.jspa?messageID=100653this application[/url] doesn’'t use the infinite while loop.

Hope that helps,

Ryan