Brunet.Symphony.StructuredNearConnectionOverlord.ConnectHandler C# (CSharp) Метод

ConnectHandler() защищенный Метод

protected ConnectHandler ( object contab, EventArgs eargs ) : void
contab object
eargs System.EventArgs
Результат void
    protected void ConnectHandler(object contab, EventArgs eargs)
    {
      lock( _sync ) {
        _last_connection_time = DateTime.UtcNow;
        _current_retry_interval = _DEFAULT_RETRY_INTERVAL;
        _need_left = -1;
        _need_right = -1;
      }

      if( IsActive == false ) {
        return;
      }

      ConnectionEventArgs args = (ConnectionEventArgs)eargs;
      Connection new_con = args.Connection;
      new_con.StateChangeEvent += this.StatusChangedHandler;
        
      ConnectionList structs = null;

      if( new_con.MainType == ConnectionType.Structured ) {
        structs = args.CList;
      } else {
        if( new_con.MainType == ConnectionType.Leaf ) {
          /*
           * We just got a leaf.  Try to use it to get a shortcut.near
           * This leaf could be connecting a new part of the network
           * to us.  We try to connect to ourselves to make sure
           * the network is connected:
           */
          Address target = GetSelfTarget();
          //This is a near neighbor connection
          ISender send = new ForwardingSender(_node, new_con.Address, target);
          //Try to connect to the two nearest to us:
          ConnectTo(send, target, STRUC_NEAR, 2);
        }
        structs = _node.ConnectionTable.GetConnections(ConnectionType.Structured);
      }
      ConnectToNearer(structs, new_con.Address, new_con.State.StatusMessage.Neighbors);
    }