Ejemplo n.º 1
0
def SendContacts(remote_idurl, json_payload={}, wide=False, callbacks={}):
    """
    """
    MyID = my_id.getLocalID()
    if _Debug:
        lg.out(
            _DebugLevel,
            "p2p_service.SendContacts to %s" % nameurl.GetName(remote_idurl))
    PacketID = packetid.UniqueID()
    try:
        json_payload['type']
        json_payload['space']
    except:
        lg.err()
        return None
    Payload = serialization.DictToBytes(json_payload)
    result = signed.Packet(
        Command=commands.Contacts(),
        OwnerID=MyID,
        CreatorID=MyID,
        PacketID=PacketID,
        Payload=Payload,
        RemoteID=remote_idurl,
    )
    gateway.outbox(result, wide=wide, callbacks=callbacks)
    return result
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

    if newpacket.Command == commands.Ack():
        # a response from remote node, typically handled in other places
        Ack(newpacket, info)

    elif newpacket.Command == commands.Fail():
        # some operation was failed on other side
        Fail(newpacket)

    elif newpacket.Command == commands.Retrieve():
        # retrieve some packet customer stored with us
        # handled by service_supplier()
        Retrieve(newpacket)

    elif newpacket.Command == commands.RequestService():
        # other node send us a request to get some service
        # handled by service_p2p_hookups()
        RequestService(newpacket, info)

    elif newpacket.Command == commands.CancelService():
        # other node wants to stop the service we gave him
        # handled by service_p2p_hookups()
        CancelService(newpacket, info)

    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)

    elif newpacket.Command == commands.ListFiles():
        # customer wants list of their files
        # handled by service_supplier()
        ListFiles(newpacket, info)

    elif newpacket.Command == commands.Files():
        # supplier sent us list of files
        # handled by service_backups()
        Files(newpacket, info)

    elif newpacket.Command == commands.DeleteFile():
        # handled by service_supplier()
        DeleteFile(newpacket)

    elif newpacket.Command == commands.DeleteBackup():
        # handled by service_supplier()
        DeleteBackup(newpacket)

    elif newpacket.Command == commands.Correspondent():
        # TODO: contact asking for our current identity, not implemented yet
        Correspondent(newpacket)

    elif newpacket.Command == commands.Broadcast():
        # handled by service_broadcasting()
        Broadcast(newpacket, info)

    elif newpacket.Command == commands.Coin():
        # handled by service_accountant()
        Coin(newpacket, info)

    elif newpacket.Command == commands.RetrieveCoin():
        # handled by service_accountant()
        RetrieveCoin(newpacket, info)

    elif newpacket.Command == commands.Key():
        # handled by service_keys_registry()
        Key(newpacket, info)

    elif newpacket.Command == commands.Event():
        # handled by service_p2p_hookups()
        Event(newpacket, info)

    elif newpacket.Command == commands.Message():
        # handled by service_private_messages()
        Message(newpacket, info)

    elif newpacket.Command == commands.Contacts():
        # handled by service_customer_family()
        Contacts(newpacket, info)

    return False
Ejemplo n.º 3
0
 def _on_inbox_packet_received(self, newpacket, info, *args):
     from p2p import commands
     if newpacket.Command == commands.Contacts():
         return self._on_incoming_contacts_packet(newpacket, info)
     return False