static void TraceRoute(IList nodes) {
Random my_r = new Random();
int idx0 = my_r.Next(0, nodes.Count);
int idx1 = my_r.Next(0, nodes.Count);
Node n0 = (Node)nodes[idx0];
Node n1 = (Node)nodes[idx1];
RpcManager pinger = n0.Rpc;
Channel results = new Channel();
Console.WriteLine("Traceroute: {0} -> {1}", n0.Address, n1.Address);
results.EnqueueEvent += delegate(object q, EventArgs a) {
object result = results.Dequeue();
RpcResult r = (RpcResult)result;
IList data = (IList)r.Result;
int hop = 0;
foreach(IDictionary d in data) {
Console.WriteLine("Hop: {0} :: {1}\n :: {2}", hop, d["node"], d["next_con"]);
hop++;
}
};
try {
pinger.Invoke(n0, results, "trace.GetRouteTo", n1.Address.ToString());
}
catch(Exception x) {
Console.WriteLine("Exception: {0}", x);
}
}