when disconnected, reset the roster

This commit is contained in:
Nathan Fritz 2010-10-20 19:33:40 -07:00
parent 77eab6544f
commit ce69213a1e

View file

@ -135,6 +135,8 @@ class BaseXMPP(XMLStream):
self.add_event_handler('presence_subscribe', self.add_event_handler('presence_subscribe',
self._handle_subscribe) self._handle_subscribe)
self.add_event_handler('disconnected',
self._handle_disconnected)
# Set up the XML stream with XMPP's root stanzas. # Set up the XML stream with XMPP's root stanzas.
self.registerStanza(Message) self.registerStanza(Message)
@ -518,6 +520,10 @@ class BaseXMPP(XMLStream):
def getjidbare(self, fulljid): def getjidbare(self, fulljid):
return fulljid.split('/', 1)[0] return fulljid.split('/', 1)[0]
def _handle_disconnected(self, event):
"""When disconnected, reset the roster"""
self.roster = {}
def _handle_message(self, msg): def _handle_message(self, msg):
"""Process incoming message stanzas.""" """Process incoming message stanzas."""
self.event('message', msg) self.event('message', msg)