XMPPConnection logout?

Hi,

Coding my SMS chat application, I was wondering why the XMPPConnection class does not provide a logout() method since it has a login() one. I have noticed that close() stops the connection with the server. To suit me more, XMPPConnection should have a logout() method that sets the presence to unavailable without closing , leaving the XMPPConnection instance in the same state as after its creation (so that login() can be called again on this instance).

But maybe, such a method is not XMPP compliant (and that is the reason why it does not exist), is it?

Thanks for your help,

Seb

Hiya,

AFAIK, you cannot re-login on the same connection.

When the connection is first made, negotions are made, t.ex. stream compression and encryption if an SSL connection.

It would be possable to have a logout method, but one would also have to have a reconnect method to create a new stream, which means there would be no advantage from creating a new XMPPConnection instance.

Pheet

An alternative that you may find useful is to set the client’‘s presence to unavailable while maintaining the underlying connection. While the presence is unavailable the server shouldn’'t be sending messages to the client. You can then turn the client back on by sending an available presence.

Just an idea…

– Gato

Pheet >> Negociations are made, but there is a state, after XMPPConnection has been instanciated and before login() method is called , where we could possibly go back with a logout() to be able to make a new login(). The only thing I do not know is that we must close the stream to return in this state…

Gato >> Indeed, I want another user to login with the same XMPPConnection so that several users can use consecutively the same object… Another idea?

Hey Seb,

That would be an interesting optimization. Unfortunately, I don’‘t think that the XMPP protocol allows to un-authenticate a connection. So I don’‘t think that it’'s possible to reuse the same connection without closing the element which in turn implies to destroy the underlying TCP connection.

This means that you will need to close the XMPPConnection and create a new one for the new user.

Regards,

– Gato

Gato >> Ok, that is the way I choose to sort out this little problem. However, I find it strange that XMPP does not enable several authentications, consecutives or multiplexed, in the same element. Such mechanisms could help to solve scaling problems…

Thanks for helping me going over this new XMPP challenge