Brunet.Tunnel.TunnelEdgeListener.DisconnectionHandler C# (CSharp) Method

DisconnectionHandler() protected method

When a disconnection occurs, we must make sure that none of our tunnels use that faulty edge / connection any more.
protected DisconnectionHandler ( object o, EventArgs ea ) : void
o object
ea System.EventArgs
return void
    protected void DisconnectionHandler(object o, EventArgs ea)
    {
      ConnectionEventArgs cea = ea as ConnectionEventArgs;
      if(cea.ConnectionType != ConnectionType.Structured) {
        return;
      }

      ConnectionList cons = cea.CList;
      Interlocked.Exchange(ref _connections, cons);;

      IList addresses = GetNearest(_node.Address, cons);
      TransportAddress ta = new TunnelTransportAddress(_node.Address, addresses);

      ArrayList tas = new ArrayList(1);
      tas.Add(ta);

      Interlocked.Exchange(ref _local_tas, tas);


      foreach(TunnelEdge te in _tunnels) {
        te.DisconnectionHandler(cea.Connection);
        if(te.IsClosed) {
          continue;
        }

        IDictionary sync_message = _ito.GetSyncMessage(te.Overlap, _node.Address, cons);
        Channel chan = new Channel(1);
        _node.Rpc.Invoke(te, chan, "tunnel.Sync", sync_message);
      }
    }