mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-23 19:19:53 +00:00
Reset the roster on disconnect instead of replacing it.
This commit is contained in:
parent
a278f79bdb
commit
e4f3b777f9
2 changed files with 25 additions and 1 deletions
|
@ -595,7 +595,7 @@ class BaseXMPP(XMLStream):
|
|||
|
||||
def _handle_disconnected(self, event):
|
||||
"""When disconnected, reset the roster"""
|
||||
self.roster = {}
|
||||
self.roster.reset()
|
||||
|
||||
def _handle_stream_error(self, error):
|
||||
self.event('stream_error', error)
|
||||
|
|
|
@ -105,6 +105,14 @@ class Roster(object):
|
|||
for node in self._rosters:
|
||||
self._rosters[node].set_backend(db)
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Reset the state of the roster to forget any current
|
||||
presence information. Useful after a disconnection occurs.
|
||||
"""
|
||||
for node in self:
|
||||
self[node].reset()
|
||||
|
||||
|
||||
class RosterNode(object):
|
||||
|
||||
|
@ -305,6 +313,15 @@ class RosterNode(object):
|
|||
return self[jid].resources.get(resource,
|
||||
default_presence)
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Reset the state of the roster to forget any current
|
||||
presence information. Useful after a disconnection occurs.
|
||||
"""
|
||||
for jid in self:
|
||||
self[jid].reset()
|
||||
|
||||
|
||||
|
||||
class RosterItem(object):
|
||||
|
||||
|
@ -725,3 +742,10 @@ class RosterItem(object):
|
|||
self.subscribe()
|
||||
if not self['to']:
|
||||
self._unsubscribed()
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Forgot current resource presence information as part of
|
||||
a roster reset request.
|
||||
"""
|
||||
self.resources = {}
|
||||
|
|
Loading…
Reference in a new issue