Ejemplo n.º 1
0
def inbox(newpacket, info, status, error_message):
    """
    """
    if newpacket.CreatorID != my_id.getLocalID(
    ) and newpacket.RemoteID != my_id.getLocalID():
        # packet is NOT for us, skip
        return False
    commandhandled = False
    if newpacket.Command == commands.Ack():
        # a response from remote node, typically handled in other places
        Ack(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.Fail():
        # some operation was failed on other side
        Fail(newpacket)
        commandhandled = False
    elif newpacket.Command == commands.Retrieve():
        # retrieve some packet customer stored with us
        # handled by service_supplier()
        Retrieve(newpacket)
        commandhandled = False
    elif newpacket.Command == commands.RequestService():
        # other node send us a request to get some service
        # handled by service_p2p_hookups()
        RequestService(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.CancelService():
        # other node wants to stop the service we gave him
        # handled by service_p2p_hookups()
        CancelService(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.Data():
        # new packet to store for customer, or data coming back from supplier
        # handled by service_backups() and service_supplier()
        Data(newpacket)
        commandhandled = False
    elif newpacket.Command == commands.ListFiles():
        # customer wants list of their files
        # handled by service_supplier()
        ListFiles(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.Files():
        # supplier sent us list of files
        # handled by service_backups()
        Files(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.DeleteFile():
        # handled by service_supplier()
        DeleteFile(newpacket)
        commandhandled = False
    elif newpacket.Command == commands.DeleteBackup():
        # handled by service_supplier()
        DeleteBackup(newpacket)
        commandhandled = False
    elif newpacket.Command == commands.Correspondent():
        # TODO: contact asking for our current identity, not implemented yet
        Correspondent(newpacket)
        commandhandled = False
    elif newpacket.Command == commands.Broadcast():
        # handled by service_broadcasting()
        Broadcast(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.Coin():
        # handled by service_accountant()
        Coin(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.RetrieveCoin():
        # handled by service_accountant()
        RetrieveCoin(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.Key():
        # handled by service_keys_registry()
        Key(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.Event():
        # handled by service_p2p_hookups()
        Event(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.Message():
        # handled by service_private_messages()
        Message(newpacket, info)
        commandhandled = False

    return commandhandled
Ejemplo n.º 2
0
def inbox(newpacket, info, status, error_message):
    """
    """
    if newpacket.CreatorID != my_id.getLocalID(
    ) and newpacket.RemoteID != my_id.getLocalID():
        # packet is NOT for us, skip
        return False

    commandhandled = False
    if newpacket.Command == commands.Ack():
        # a response from remote node, typically handled in other places
        Ack(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.Fail():
        # some operation was failed on other side
        Fail(newpacket)
        commandhandled = False
    elif newpacket.Command == commands.Retrieve():
        # retrieve some packet customer stored with us
        Retrieve(newpacket)
        commandhandled = True
    elif newpacket.Command == commands.RequestService():
        # other node send us a request to get some service
        RequestService(newpacket, info)
        commandhandled = True
    elif newpacket.Command == commands.CancelService():
        # other node wants to stop the service we gave him
        CancelService(newpacket, info)
        commandhandled = True
    elif newpacket.Command == commands.Data():
        # new packet to store for customer
        commandhandled = Data(newpacket)
    elif newpacket.Command == commands.ListFiles():
        # customer wants list of their files
        ListFiles(newpacket)
        commandhandled = True
    elif newpacket.Command == commands.Files():
        # supplier sent us list of files
        Files(newpacket, info)
        commandhandled = True
    elif newpacket.Command == commands.DeleteFile():
        # will Delete a customer file for them
        DeleteFile(newpacket)
        commandhandled = True
    elif newpacket.Command == commands.DeleteBackup():
        # will Delete all files starting in a backup
        DeleteBackup(newpacket)
        commandhandled = True
    elif newpacket.Command == commands.Message():
        # will be handled in message.py
        commandhandled = False
    elif newpacket.Command == commands.Correspondent():
        # contact asking for our current identity
        Correspondent(newpacket)
        commandhandled = True
    elif newpacket.Command == commands.Broadcast():
        # handled by service_broadcasting()
        Broadcast(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.Coin():
        # handled by service_accountant()
        Coin(newpacket, info)
        commandhandled = False
    elif newpacket.Command == commands.RetrieveCoin():
        # handled by service_accountant()
        RetrieveCoin(newpacket, info)
        commandhandled = False

    return commandhandled