Esempio n. 1
0
def handle(message,accountkey,receiver):
    try:
        coremessage = msgpack.depack(message['message'])
        is_xi_message = coremessage['xi']

        # put message['message'] to Xi
        tag = json.dumps({'tag':coremessage['tag'],'timestamp':message['timestamp'],'account':accountkey}).encode('hex')

        if xisupport.XI_ENABLED and is_xi_message:    
            xisupport.xi_queue(message['sender'],receiver,tag,coremessage['message'],False)
            # Retrive Xi handled messages and parse that.
            handled = xisupport.xi_handled(False)
            for i in handled:
                handle_kernel(i[0],i[1],i[2],i[3],True) # SENDER RECEIVER TAG BODY
        else:
            handle_kernel(message['sender'],receiver,tag,coremessage['message'],False)
    except Exception,e:
        print "Error handling message: %s" % e
Esempio n. 2
0
def handle(message,sender):
    try:
#        print message,sender
        coremessage = msgpack.depack(message)
        is_xi_message = coremessage['xi']
        entity_sender = entity.getNicknameByJID(sender)

        # put message['message'] to Xi
        tag = json.dumps({'xi':is_xi_message,
                          'tag':coremessage['tag'],
                          'timestamp':coremessage['timestamp']}).encode('hex')

        if xisupport.XI_ENABLED and is_xi_message:
            xisupport.xi_queue(entity_sender,utils.myname,tag,coremessage['message'],False)
            # Retrive Xi handled messages and parse that.
            handled = xisupport.xi_handled(False)
            for i in handled:
                handle_kernel(i[0],i[1],i[2],i[3]) # SENDER RECEIVER TAG BODY
        else:
            handle_kernel(entity_sender,utils.myname,tag,coremessage['message'])
    except Exception,e:
        print "Error handling message: %s" % e