Connecting to an XMPP server with XMPPPY is simple.
from xmpp.client import Client as XMPPClient
self.xmppClient = XMPPClient("jabber.foo.com")
if not self.xmppClient.connect(server="localhost"):
raise IOError('Cannot connect to server.')
if not self.xmppClient.auth("node", "password", "resource"):
raise IOError('Can not auth with server.')
self.xmppClient.RegisterHandler("message", self.messageHandler)
self.xmppClient.sendInitPresence()
However, there are times when my client has to force a disconnect, yet still keep going doing other things. I'd like to make sure that the client disconnects properly - that the socket is not 'hanging around' and the server resources are not being wasted.
Is the intended pattern to simply set the client to None and let GC clean up the object?
self.xmppClient = None
I see "disconnected handlers" in the client, but I do not see how to invoke them. And the documentation that comes with XMPPPY is horrible.
Anyone have any clue of the "right way" to disconnect?