def __onStanzaMessage(self, stanza): from_jid = getAttr(stanza, 'from').encode('utf-8') user = jidAttr(from_jid, 'muc_user') messageType = getAttr(stanza, 'type') if messageType == 'error': return body = getChild(stanza, 'body') if not body: return self.eventMessage(user, body['data'].encode('utf-8'))
def __onStateOnline(self, stanza): stanzaName = stanza['name'] stanzaFrom = getAttr(stanza, 'from') or u'' stanzaId = getAttr(stanza, 'id') or u'' bare_jid = jidAttr(stanzaFrom, 'bare') entity = self.entities.get(bare_jid) if entity: entity.onStanza(stanza) try: match = re.match(XMPPConnection.Connection.STANZA_ID_TEMPLATE, stanzaId) if match: self.tasks[int(match.group(1))].digest(stanza, int(match.group(2))) except: LOG_CURRENT_EXCEPTION() if stanzaName == 'stream:error': child = getChild(stanza, 'system-shutdown') if child: LOG_ERROR('XMPP: Stream error: %s' % stanza) self.__onServerDisconnected() return
def __onStateOnline(self, stanza): stanzaName = stanza['name'] if not getAttr(stanza, 'from'): stanzaFrom = u'' if not getAttr(stanza, 'id'): stanzaId = u'' bare_jid = jidAttr(stanzaFrom, 'bare') entity = self.entities.get(bare_jid) if entity: entity.onStanza(stanza) try: match = re.match( XMPPConnection.Connection.STANZA_ID_TEMPLATE, stanzaId) if match: self.tasks[int(match.group(1))].digest( stanza, int(match.group(2))) except: LOG_CURRENT_EXCEPTION() child = stanzaName == 'stream:error' and getChild( stanza, 'system-shutdown') child and LOG_ERROR('XMPP: Stream error: %s' % stanza) self.__onServerDisconnected() return