当前位置: 首页>>代码示例>>C#>>正文


C# Brunet.Node类代码示例

本文整理汇总了C#中Brunet.Node的典型用法代码示例。如果您正苦于以下问题:C# Node类的具体用法?C# Node怎么用?C# Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Node类属于Brunet命名空间,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ManagedConnectionOverlord

 public ManagedConnectionOverlord(Node node) {
   _sync = new Object();
   _active = false;
   _node = node;
   _connection_state = new Dictionary<Address, MCState>();
   _last_call = DateTime.MinValue;
 }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:7,代码来源:ManagedConnectionOverlord.cs

示例2: RpcDht

 public RpcDht(IDht dht, Node node) {
   LocalUseOnly = true;
   _channels = new Brunet.Collections.Cache(100);
   _node = node;
   _dht = dht;
   _node.Rpc.AddHandler("DhtClient", this);
 }
开发者ID:johnynek,项目名称:brunet,代码行数:7,代码来源:RpcDht.cs

示例3: RpcDht

 public RpcDht(IDht dht, Node node) {
   LocalUseOnly = true;
   _bqs = new Cache(100);
   _node = node;
   _dht = dht;
   _node.Rpc.AddHandler("DhtClient", this);
 }
开发者ID:kyungyonglee,项目名称:BrunetTutorial,代码行数:7,代码来源:RpcDht.cs

示例4: DeetooCluster

		//protected object _sync;

		public DeetooCluster(Node cnode, Node qnode, double x, double y) {
			//_sync = new object();
			_cnode = cnode;
			_qnode = qnode;
			_coor_x = x;
			_coor_y = y;
		}
开发者ID:hseom,项目名称:hseom_brunet,代码行数:9,代码来源:DeetooCluster.cs

示例5: StateChangeHandler

    /// <summary> Occassionally nodes will get a true return from a allocation
    /// attempt, in order to prevent this, we reissue all dhcp requests after
    /// getting "connected" to the overlay.</summary>
    protected void StateChangeHandler(Node n, Node.ConnectionState state) {
      List<MemBlock> ips = null;

      lock(_sync) {
        if(state == Node.ConnectionState.Connected) {
          if(_connected) {
            return;
          }
          AppNode.Node.StateChangeEvent -= StateChangeHandler;
          _connected = true;
        } else {
          return;
        }

        ips = new List<MemBlock>(_ip_to_ether.Keys.Count);
        foreach(MemBlock ip in _ip_to_ether.Keys) {
          ips.Add(ip);
        }
      }

      WaitCallback callback = delegate(object o) {
        // Get a new Dhcp server so we get new state!
        DhcpServer dhcp_server = GetDhcpServer();
        foreach(MemBlock ip in ips) {
          try {
            dhcp_server.RequestLease(ip, true, AppNode.Node.Address.ToString(),
                _ipop_config.AddressData.Hostname);
          } catch(Exception e) {
            ProtocolLog.WriteIf(IpopLog.DhcpLog, e.Message);
          }
        }
      };

      ThreadPool.QueueUserWorkItem(callback, null);
    }
开发者ID:acisp2p,项目名称:brunet,代码行数:38,代码来源:DhtIpopNode.cs

示例6: StructuredNearConnectionOverlord

    public StructuredNearConnectionOverlord(Node n)
    {
      _sync = new Object();
      lock( _sync ) {
        _node = n;
        _rand = new Random();
        _connectors = new Hashtable();
        _last_connection_time = DateTime.UtcNow;
      /**
       * Every heartbeat we assess the trimming situation.
       * If we have excess edges and it has been more than
       * _trim_wait_time heartbeats then we trim.
       */
        _last_retry_time = DateTime.UtcNow;
        _current_retry_interval = _DEFAULT_RETRY_INTERVAL;

        /**
         * Information related to the target selector feature.
         * Includes statistics such as trim rate and connection lifetimes.
         */
        
        _start_time = DateTime.UtcNow;
        
        /*
         * Register event handlers after everything else is set
         */
        //Listen for connection events:
        _node.ConnectionTable.DisconnectionEvent += DisconnectHandler;
        _node.ConnectionTable.ConnectionEvent += ConnectHandler;
        _node.ConnectionTable.StatusChangedEvent += StatusChangedHandler;
        
        _node.HeartBeatEvent += CheckState;
      }
    }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:34,代码来源:StructuredNearConnectionOverlord.cs

示例7: TunnelEdgeListener

    public TunnelEdgeListener(Node node, ITunnelOverlap ito, IForwarderSelectorFactory iasf)
    {
      _ito = ito;
      _iasf = iasf;
      _oco = new OverlapConnectionOverlord(node);
      _node = node;
      _running = 0;
      _started = 0;
      _id_to_tunnel = new Dictionary<int, TunnelEdge>();
      _sync = new object();

      TransportAddress ta = new TunnelTransportAddress(node.Address, new List<Address>());
      ArrayList local_tas = new ArrayList(1);
      local_tas.Add(ta);
      _local_tas = local_tas;

      _node.DemuxHandler.GetTypeSource(PType.Protocol.Tunneling).Subscribe(this, null);
      _node.ConnectionTable.ConnectionEvent += ConnectionHandler;
      _node.ConnectionTable.DisconnectionEvent += DisconnectionHandler;

      ConnectionList cons = _node.ConnectionTable.GetConnections(ConnectionType.Structured);
      Interlocked.Exchange(ref _connections, cons);
      _node.Rpc.AddHandler("tunnel", this);
      _oco_trim_timer = Brunet.Util.FuzzyTimer.Instance.DoEvery(OcoTrim, _oco_trim_timeout, 0);
    }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:25,代码来源:TunnelEdgeListener.cs

示例8: Agent

 public Agent(Node n, IAcceptor read_acceptor, IAcceptor write_acceptor) {
   _rand = new Random();
   /**
    * @todo Make a heartbeat handler which will use the Node HeartbeatEvent
    * to resend packets after the timeout
    */
 }
开发者ID:xujyan,项目名称:brunet,代码行数:7,代码来源:Agent.cs

示例9: AddressInSubjectAltName

    ///<summary>Verify the edge by comparing the address in the certificate to
    ///the one provided in the overlay.</summary>
    public static bool AddressInSubjectAltName(Node node, Edge e, Address addr) {
      SecureEdge se = e as SecureEdge;
      if(se == null) {
        throw new Exception("Invalid edge type!");
      }

      return se.SA.VerifyCertificateBySubjectAltName(addr.ToString());
    }
开发者ID:kyungyonglee,项目名称:BrunetTutorial,代码行数:10,代码来源:EdgeVerification.cs

示例10: Dht

 /**
 <summary>A default Dht client provides a DEGREE of 1 and a sychronous wait
 time of up to 60 seconds.</summary>
 <param name ="node">The node to provide service for.</param>
 */
 public Dht(Node node) {
   this.node = node;
   _rpc = RpcManager.GetInstance(node);
   _table = new TableServer(node);
   DEGREE = 1;
   MAJORITY = 1;
   DELAY = 60000;
 }
开发者ID:xujyan,项目名称:brunet,代码行数:13,代码来源:Dht.cs

示例11: RpcDhtProxy

 /// <summary>Initiates a RpcProxyHandler instance. It uses reflection for rpc call.
 /// Thus, it does not have to inherit IRpcHanler.This instance keeps Entry
 /// to keep track of key, value, and ttl</summary>
 /// <param name="node">node which is currently connected.</param>
 /// <param name="dht">IDht instance</param>
 public RpcDhtProxy(IDht dht, Node node)
 {
   _entries = new Dictionary<MemBlock, Dictionary<MemBlock, Entry>>();
   _rpc = node.Rpc;
   _dht = dht;
   _sync = new Object();
   _rpc.AddHandler("RpcDhtProxy", this);
 }
开发者ID:bakriy,项目名称:brunet,代码行数:13,代码来源:RpcDhtProxy.cs

示例12: CreateInstance

 /**
  * Returns an instance of an ISender, given its URI representation.
  * @param n node on which the sender is attached. 
  * @param uri URI representation of the sender.
  * @returns an ISender object.
  * @throws SenderFactoryException when URI is invalid or unsupported. 
  */
 public static ISender CreateInstance(Node n, string uri) {
   int varidx;
   try {
     string type = GetScheme(uri, out varidx);
     return _handlers[type](n, uri);
   } catch {
     throw new SenderFactoryException("Cannot parse URI: " + uri);         
   }
 }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:16,代码来源:SenderFactory.cs

示例13: CreateInstance

 protected static AHSender CreateInstance(Node n, string uri) {
   string s = uri.Substring(7);
   string []ss = s.Split(SenderFactory.SplitChars);
   string []dest = ss[1].Split(SenderFactory.Delims);
   Address target = AddressParser.Parse(dest[1]);
   string mode = (ss[2].Split(SenderFactory.Delims))[1];
   ushort option = SenderFactory.StringToUShort(mode);
   return new AHSender(n, target, option);
 }
开发者ID:kyungyonglee,项目名称:BrunetTutorial,代码行数:9,代码来源:AHSender.cs

示例14: ConnectionHandlerTest

    protected void ConnectionHandlerTest(Node node0, Node node1,
        ConnectionHandler ch0, ConnectionHandler ch1)
    {
      Console.WriteLine(node0.Address + " " + node1.Address);
      var mdh0 = new MockDataHandler();
      var mdh1 = new MockDataHandler();
      MemBlock zero = MemBlock.Reference(new byte[] {0});
      EventHandler cb = delegate(object o, EventArgs ea) {
        Assert.AreEqual(o, zero, "Zero");
      };

      mdh0.HandleDataCallback += cb;
      mdh1.HandleDataCallback += cb;
      ch0.Subscribe(mdh0, null);
      ch1.Subscribe(mdh1, null);

      Assert.AreEqual(mdh0.Count, 0, "MDH0 0");
      Assert.AreEqual(mdh1.Count, 0, "MDH1 0");
      ch0.ConnectTo(node1.Address);
      Assert.IsTrue(AreConnected(node0, node1), "ConnectionHandler ConnectTo");
      SimpleTimer.RunSteps(fifteen_mins * 2);
      Assert.IsFalse(Simulator.AreConnected(node0, node1));
      ch0.Send(node1.Address, zero);
      SimpleTimer.RunSteps(fifteen_mins / 60);
      Assert.AreEqual(mdh0.Count, 0, "MDH0 1");
      Assert.AreEqual(mdh1.Count, 0, "MDH1 1");
      Assert.IsTrue(AreConnected(node0, node1), "ConnectionHandler ConnectTo");
      SimpleTimer.RunSteps(fifteen_mins / 3);
      ch0.Send(node1.Address, zero);
      SimpleTimer.RunSteps(fifteen_mins / 60);
      Assert.AreEqual(mdh0.Count, 0, "MDH0 2");
      Assert.AreEqual(mdh1.Count, 1, "MDH1 2");
      Assert.IsTrue(Simulator.AreConnected(node0, node1), "Continuous 0");
      SimpleTimer.RunSteps(fifteen_mins / 3);
      ch0.Send(node1.Address, zero);
      SimpleTimer.RunSteps(fifteen_mins / 60);
      Assert.AreEqual(mdh0.Count, 0, "MDH0 3");
      Assert.AreEqual(mdh1.Count, 2, "MDH1 3");
      Assert.IsTrue(Simulator.AreConnected(node0, node1), "Continuous 1");
      SimpleTimer.RunSteps(fifteen_mins / 3);
      ch0.Send(node1.Address, zero);
      SimpleTimer.RunSteps(fifteen_mins / 60);
      Assert.AreEqual(mdh0.Count, 0, "MDH0 4");
      Assert.AreEqual(mdh1.Count, 3, "MDH1 4");
      Assert.IsTrue(Simulator.AreConnected(node0, node1), "Continuous 2");
      SimpleTimer.RunSteps(fifteen_mins / 3);
      ch1.Send(node0.Address, zero);
      SimpleTimer.RunSteps(fifteen_mins / 60);
      Assert.AreEqual(mdh0.Count, 1, "MDH0 5");
      Assert.AreEqual(mdh1.Count, 3, "MDH1 5");
      Assert.IsTrue(Simulator.AreConnected(node0, node1), "Continuous 3");
      SimpleTimer.RunSteps(fifteen_mins * 2);
      Assert.IsFalse(Simulator.AreConnected(node0, node1), "Dead");
      Assert.AreEqual(mdh0.Count, 1, "MDH0 6");
      Assert.AreEqual(mdh1.Count, 3, "MDH1 6");
    }
开发者ID:acisp2p,项目名称:brunet,代码行数:56,代码来源:SimulatorUnit.cs

示例15: Add

 public void Add(Node n) {
   lock( _sync ) {
     _node_list.Add(n);  
     _sorted_adds.Add(n.Address);
     _sorted_adds.Sort(new AHAddressComparer());
     //monitor the connection table:
     ConnectionTable ct = n.ConnectionTable;
     _ctable_to_node[ ct ] = n; 
     ct.ConnectionEvent += new EventHandler(this.ConnectionTableChangeHandler);
     ct.DisconnectionEvent += new EventHandler(this.ConnectionTableChangeHandler);
   }
 }
开发者ID:johnynek,项目名称:brunet,代码行数:12,代码来源:BootStrapTester.cs


注:本文中的Brunet.Node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。