Beispiel #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
Beispiel #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
Beispiel #3
0
        try:
            fp = open(options.input,'r')
            message = fp.read()
            fp.close()
        except Exception,e:
            print "File reading error: %s" % e
            exit()

# xi.postoffice support here.
if xisupport.XI_ENABLED and (options.usexi or user_usexi):

    if not options.omit:
        tag = json.dumps({'host':host,'secret':secret,'bits':bits,'tag':options.tag}).encode('hex')
        xisupport.xi_queue(user,options.receiver,tag,message)

    handleds = xisupport.xi_handled(True)
    for p in handleds:
        try:
            tag      = json.loads(p[2].decode('hex'))

            host     = tag['host']
            user     = p[0] # SENDER
            secret   = tag['secret']
            receiver = p[1] # RECEIVER
            
            # BODY
            message  = msgpack.enpack(tag['tag'],p[3],True)

            bits     = tag['bits']

            print "[%s] to [%s] is pushing." % (user,receiver)