Brunet.Services.Dht.TableServer.HandleRpc C# (CSharp) Метод

HandleRpc() публичный Метод

This provides faster translation for Rpc methods as well as allows for Asynchronous Rpc calls which are required for Puts and Creates.
Thrown when there the method is not Put, PutHandler, Get, Dump, or Count
public HandleRpc ( ISender caller, string method, IList args, object rs ) : void
caller ISender The ISender who made the request.
method string The method requested.
args IList A list of arguments to pass to the method.
rs object The return state sent back to the RpcManager so that it knows who to return the result to.
Результат void
    public void HandleRpc(ISender caller, string method, IList args, object rs) {
      object result = null;
      try {
        if(method.Equals("Put")) {
          MemBlock key = (byte[]) args[0];
          MemBlock value = (byte[]) args[1];
          int ttl = (int) args[2];
          bool unique = (bool) args[3];
          Put(key, value, ttl, unique, rs);
          return;
        }
        else if(method.Equals("PutHandler")) {
          MemBlock key = (byte[]) args[0];
          MemBlock value = (byte[]) args[1];
          int ttl = (int) args[2];
          bool unique = (bool) args[3];
          result = PutHandler(key, value, ttl, unique);
        }
        else if(method.Equals("Get")) {
          MemBlock key = (byte[]) args[0];
          // Hack for backwards compatibility, supports forwards too
          int token_pos = args.Count - 1;
          if(args[token_pos] == null) {
           result = Get(key, null);
          }
          else {
            result = Get(key, (byte[]) args[token_pos]);
          }
        }
        else if(method.Equals("Dump")) {
          lock(_sync) {
            result = _data.Dump();
          }
        }
        else if(method.Equals("Count")) {
          result = Count;
        }
        else {
          throw new Exception("Dht.Exception:  Invalid method");
        }
      }
      catch (Exception e) {
        result = new AdrException(-32602, e);
      }
      _rpc.SendResult(rs, result);
    }