powered by Jive Software

XMPPConnection.connect method doesn''t exist

Developers,

I’‘m using Smack for some inter-process communication and have a question/observation about the XMPPConnection class. The instantiation performs the server connection after which I can add connectionListeners. If the connection dies, I can’‘t just call a XMPPConnection.connect method, it doesn’‘t exist. I have to create a new XMPPConnection object. Then somehow, I have to reconnect the old connection’‘s connectionlisteners to the new connection. Is this correct? or is there a XMPPConnection.connect method, the online API (1.4.1) docs don’'t show one.

Please consider adding a connect method to XMPPConnection for reconnection after disconnect.

Also, I don’‘t see how a ConnectionEstablishedListener does any good when you can’'t attach a listener until after the XMPPConnection instantiation completes with a successful connection. Am I missing something here?

Thanks for your time.

Craig

I poked around the source a little bit. It seems like XMPPConnection.init could be renamed XMPPConnection.connect and made public. I guess I can extend XMPPConnection and do this.

I still don’‘t see how the connectionEstablishedListeners were supposed to work. Since you can’'t add them until after the connection is established.

Craig

OK, I’‘m back again, answering my own question. You can’‘t subclass XMPPConnection creating a method called connect. This connect would need to call XMPPConnection.init, which the subclass can’‘t because is private. So I’'m stuck.

Can anyone help here?

Thanks

Craig,

I think this is good feedback. The original idea was to keep the API as simple as possible, but adding a connect method doesn’'t increase the developer burden significantly and would improve functionality quite a bit.

We could look at adding something for Smack 1.5. If you need this feature critically now, I’'d recommend just modifying the Smack code directly. In fact, if you do so and find a good way to implement the changes, please let us know.

Thanks,

Matt

Matt,

Here’'s my suggestion that offers functionality and backward compatibility.

Create new constructor

public XMPPConnection(String host, int port, boolean connect)

{

set host, port, make socket, etc;

if (connect){

init();

}

public connect() {

this.init();

}

Craig

public XMPPConnection(String host, int port, boolean connect)

{

set host, port, make socket, etc;

if (connect){

init();

}

public connect() {

this.init();

}

//===========================

this is new constructor add for smack is very good !

I’‘ve added this feature request as SMACK-52. We’'ll aim to get it into the next release.

Thanks!

-Matt

Thanks!