Beispiel #1
0
    /// <summary>
    /// OpenDHTLib Test compatible with OpenDHT python scripts (http://www.opendht.org/)
    /// </summary>
    public static void Main()
    {
        string line = new string('-', 80);

        string[]       res     = new string[] { "Success", "Capacity", "Again" };
        OpenDHT        openDHT = new OpenDHT();
        OpenDHTMessage message = new OpenDHTMessage("OpenDHT.Net-Key", string.Empty, "OpenDHT.Net-Secret", 100);

        message.Content = "OpenDHT.Net-Value";
        Console.WriteLine("Put : " + res[openDHT.Put(message)]);

        Console.WriteLine("Get : ");
        foreach (string value in openDHT.GetStringValues(message.KeyStr))
        {
            Console.WriteLine(value);
        }
        Console.WriteLine(line);

        message.Content = "OpenDHT.Net-Value1";
        Console.WriteLine("PutRemovable : " + res[openDHT.PutRemovable(message)]);
        message.Content = "OpenDHT.Net-Value2";
        Console.WriteLine("PutRemovable : " + res[openDHT.PutRemovable(message)]);
        Console.WriteLine(line);

        Console.WriteLine("GetDetails :");
        foreach (OpenDHTMessageDetails msg in openDHT.GetDetailsStringValues(message.KeyStr))
        {
            Console.WriteLine(msg);
        }
        Console.WriteLine(line);

        message.Content = "OpenDHT.Net-Value1";
        Console.WriteLine("Remove : " + res[openDHT.Rm(message)]);
        Console.WriteLine(line);

        message.Content = "OpenDHT.Net-Value2";
        message.Secret  = "OpenDHT.Net-SecretFoo";
        Console.WriteLine("Remove Fails : " + res[openDHT.Rm(message)]);
        Console.WriteLine(line);

        Console.WriteLine("GetDetails :");
        foreach (OpenDHTMessageDetails msg in openDHT.GetDetailsStringValues(message.KeyStr))
        {
            Console.WriteLine(msg);
        }
        Console.WriteLine(line);
    }
Beispiel #2
0
 public override void Put(byte[] key, byte[] value, int ttl)
 {
     Convert.ToBoolean(_dht.Put(key, value, ttl, ""));
 }