예제 #1
0
 def __onStanzaPresence(self, stanza):
     from_jid = getAttr(stanza, 'from').encode('utf8')
     user = jidAttr(from_jid, 'muc_user')
     presenceType = getAttr(stanza, 'type')
     if not presenceType:
         presenceType = 'available'
     self.eventUserOffline(user) if presenceType == 'unavailable' else self.eventUserOnline(user)
예제 #2
0
 def __onStanzaPresence(self, stanza):
     from_jid = getAttr(stanza, 'from').encode('utf8')
     user = jidAttr(from_jid, 'muc_user')
     presenceType = getAttr(stanza, 'type')
     if not presenceType:
         presenceType = 'available'
     self.eventUserOffline(
         user) if presenceType == 'unavailable' else self.eventUserOnline(
             user)
예제 #3
0
 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'))
예제 #4
0
 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'))
예제 #5
0
파일: client.py 프로젝트: Infernux/Projects
 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 
예제 #6
0
    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