protected void AttemptToCreateOverlap(TunnelEdgeCallbackAction teca)
{
WaitCallback create_connection = delegate(object o) {
Address target = o as Address;
if(o == null) {
FailedEdgeCreate(teca);
return;
}
ConnectionList cons = _connections;
int index = cons.IndexOf(target);
if(index < 0) {
FailedEdgeCreate(teca);
return;
}
List<Connection> overlap = new List<Connection>(1);
overlap.Add(cons[index]);
CreateEdge(teca, overlap);
};
Channel chan = new Channel(1);
chan.CloseEvent += delegate(object o, EventArgs ea) {
Address target = null;
try {
IDictionary msg = (chan.Dequeue() as RpcResult).Result as IDictionary;
target = _ito.EvaluatePotentialOverlap(msg);
} catch {
}
if(target == null) {
FailedEdgeCreate(teca);
} else {
_oco.ConnectTo(target, create_connection);
}
};
ISender s = new AHExactSender(_node, teca.TunnelTA.Target);
_node.Rpc.Invoke(s, chan, "tunnel.RequestSync");
}