• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Brunet.Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ConnectionPacketHandler

 /**
  * You should subscribe this to a Node, with the state being the node
  * it is subscribed to.  It can work for more than one node
  * simultaneously.
  */
 public ConnectionPacketHandler(Node n)
 {
   _sync = new object();
   _edge_to_cphstate = new Hashtable();
   _node = n;
   _disconnecting = 0;
   //When Disconnect is called, set disconnecting to true, disallowing new
   //connections.
   _node.DepartureEvent += delegate(object o, EventArgs a) {
     Interlocked.Exchange(ref _disconnecting, 1);
   };
 }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:17,代码来源:ConnectionPacketHandler.cs


示例17: LocalHT

        public LocalHT()
        {
            AHAddress addr = new AHAddress(new RNGCryptoServiceProvider());
              Node brunetNode = new StructuredNode(addr);
              RpcManager rpc = RpcManager.GetInstance(brunetNode);
              this._ts = new TableServer(brunetNode);
              this._node = brunetNode;

            #if FUSE_DEBUG
              //Having some init data isn't bad
              string key = FuseDhtUtil.GenDhtKey("testbasedir", "testkey1", "ipop_ns");
              this.Put(key, "testvalue1", 5000);
              this.Put(key, "testvalue2", 3000);
            #endif
        }
开发者ID:xujyan,项目名称:hurricane,代码行数:15,代码来源:LocalHT.cs


示例18: TableServer

    /**
    <summary>Creates a new TableServer object and registers it to the "dht"
    handler in the node's RpcManager.</summary>
    <param name="node">The node the dht is to serve from.</param>
    */
    public TableServer(Node node) {
      _sync = new Object();
      _transfer_sync = new Object();

      _node = node;
      _rpc = node.Rpc;

      _data = new TableServerData(_node);
      lock(_transfer_sync) {
        node.ConnectionTable.ConnectionEvent += this.ConnectionHandler;
        node.ConnectionTable.DisconnectionEvent += this.ConnectionHandler;
        _node.StateChangeEvent += StateChangeHandler;
      }

      _rpc.AddHandler("dht", this);
    }
开发者ID:johnynek,项目名称:brunet,代码行数:21,代码来源:TableServer.cs


示例19: LocalConnectionOverlord

    public LocalConnectionOverlord(Node node) {
      _sync = new Object();
      _allow_localcons = false;
      _active = false;
      _local_addresses = new List<AHAddress>();
      _node = node;

      lock(_sync) {
        _rpc = RpcManager.GetInstance(node);
        _rpc.AddHandler("LocalCO", this);

        _node.HeartBeatEvent += CheckConnection;
        _node.StateChangeEvent += StateChangeHandler;
        _node.ConnectionTable.ConnectionEvent += ConnectHandler;
        _node.ConnectionTable.DisconnectionEvent += DisconnectHandler;
        _last_announce_call = DateTime.MinValue;
        _last_activate_call = DateTime.MinValue;
      }
    }
开发者ID:xujyan,项目名称:brunet,代码行数:19,代码来源:LocalConnectionOverlord.cs


示例20: StructuredShortcutConnectionOverlord

    public StructuredShortcutConnectionOverlord(Node n)
    {
      _sync = new Object();
      lock( _sync ) {
        _node = n;
        _rand = new Random();
        _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.
         */
        
        _target_selector = new DefaultTargetSelector();
        _last_optimize_time = DateTime.UtcNow;
        _sum_con_lifetime = 0.0;
        _start_time = DateTime.UtcNow;
        _trim_count = 0;
        _shortcuts = 0;

        /*
         * Register event handlers after everything else is set
         */
        //Listen for connection events:
        _node.ConnectionTable.DisconnectionEvent += DisconnectHandler;
        _node.ConnectionTable.ConnectionEvent += ConnectHandler;
        
        _node.HeartBeatEvent += CheckState;
        _node.HeartBeatEvent += CheckConnectionOptimality;
      }
    }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:38,代码来源:StructuredShortcutConnectionOverlord.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Symphony.AHAddress类代码示例发布时间:2022-05-24
下一篇:
C# Brunet.MemBlock类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap