'Enable or resume stream management.
If no SM-ID is stored, and resource binding has taken place,
stream management will be enabled.
If an SM-ID is known, and the server allows resumption, the
previous stream will be resumed.'

def _handle_sm_feature(self, features):

    if ('stream_management' in self.xmpp.features):
        return False
    if (not self.sm_id):
        if ('bind' in self.xmpp.features):
            self.enabled.set()
            enable = stanza.Enable(self.xmpp)
            enable['resume'] = self.allow_resume
            enable.send(now=True)
            self.handled = 0
    elif (self.sm_id and self.allow_resume):
        self.enabled.set()
        resume = stanza.Resume(self.xmpp)
        resume['h'] = self.handled
        resume['previd'] = self.sm_id
        resume.send(now=True)
        waiter = Waiter('resumed_or_failed', MatchMany([MatchXPath(stanza.Resumed.tag_name()), MatchXPath(stanza.Failed.tag_name())]))
        self.xmpp.register_handler(waiter)
        result = waiter.wait()
        if ((result is not None) and (result.name == 'resumed')):
            return True
    return False
