AsyncGet() public method

This starts the get process by sending dht.Get to all the remote end points that contain the key we're looking up. The next step is is when the results are placed in the channel and GetEnqueueHandler is called or GetCloseHandler is called. This means the get needs to be stateful, that information is stored in the _adgs_table.
public AsyncGet ( MemBlock key, Channel returns ) : void
key MemBlock
returns Channel
return void
Esempio n. 1
0
    override public void Start()
    {
      Channel returns = new Channel();
      returns.EnqueueEvent += delegate(object o, EventArgs ea) {
        while(returns.Count > 0) {
          Hashtable result = null;
          try {
            result = returns.Dequeue() as Hashtable;
          } catch {
            continue;
          }

          byte[] res = result["value"] as byte[];
          if(res != null) {
            Results.Enqueue(MemBlock.Reference(res));
          }
        }
        if(_enqueue != null) {
          _enqueue(this, EventArgs.Empty);
        }
      };

      returns.CloseEvent += delegate(object o, EventArgs ea) {
        Finished();
      };

      Dht dht = new Dht(Node, 3, 20);
      dht.AsyncGet(Key, returns);
    }