Stores SubringTransportAddress in the form of brunet.subring://$Address The Address should be the shared overlays Address.
Inheritance: Brunet.Transport.TransportAddress
コード例 #1
0
        public override void CreateEdgeTo(TransportAddress ta, EdgeCreationCallback ecb)
        {
            SubringTransportAddress sta = ta as SubringTransportAddress;

            if (sta == null)
            {
                ecb(false, null, new Exception("TA Type is not Subring!"));
            }
            else if (!sta.Namespace.Equals(_shared_node.Realm))
            {
                ecb(false, null, new Exception("Namespace mismatch"));
            }
            else if (sta.Target.Equals(_private_node.Address))
            {
                ecb(false, null, new Exception("You are me!"));
            }
            else
            {
                SubringEdge se = new SubringEdge(_local_ta, sta, false,
                                                 new AHExactSender(_shared_node, sta.Target), _ptype);
                se.CloseEvent += CloseHandler;
                _it.Add(se);
                ecb(true, se, null);
            }
        }
コード例 #2
0
        public void Test()
        {
            SubringTransportAddress sta = new SubringTransportAddress(
                new AHAddress(Base32.Decode("CADSL6GVVBM6V442CETP4JTEAWACLC5A")),
                "ns.ns0.ns1");
            string           ta_string = "brunet.subring://CADSL6GVVBM6V442CETP4JTEAWACLC5A.ns.ns0.ns1";
            TransportAddress ta        = TransportAddressFactory.CreateInstance(ta_string);

            Assert.AreEqual(ta, sta, "TA == STA -- 1");

            ta_string = "brunet.subring://CADSL6GVVBM6V442CETP4JTEAWACLC5A.ns.ns0.ns1/";
            ta        = TransportAddressFactory.CreateInstance(ta_string);
            Assert.AreEqual(ta, sta, "TA == STA -- 2");
        }
コード例 #3
0
        public override bool Equals(object o)
        {
            if (o == this)
            {
                return(true);
            }

            SubringTransportAddress other = o as SubringTransportAddress;

            if (other == null)
            {
                return(false);
            }

            return(Target.Equals(other.Target));
        }
コード例 #4
0
        /// <summary>Where data packets prepended with a prepended subring come.
        /// Here we receive data as well as create new SubringEdges.</summary>
        public void HandleData(MemBlock data, ISender return_path, object state)
        {
            AHSender from = return_path as AHSender;

            if (from == null)
            {
                return;
            }

            AHAddress target = (AHAddress)from.Destination;
            MemBlock  payload;
            int       local_id, remote_id;

            _it.Parse(data, out payload, out local_id, out remote_id);

            IIdentifierPair ip;
            SubringEdge     se;

            if (_it.TryGet(local_id, remote_id, out ip))
            {
                se = ip as SubringEdge;
            }
            else if (local_id == 0)
            {
                if (!from.Node.Realm.Equals(_shared_node.Realm))
                {
                    // We don't have matching realms
                    return;
                }
                var rem_sta = new SubringTransportAddress(target, from.Node.Realm);
                se = new SubringEdge(_local_ta, rem_sta, true, from, _ptype);
                _it.Add(se);
                se.RemoteID    = remote_id;
                se.CloseEvent += CloseHandler;
                SendEdgeEvent(se);
            }
            else
            {
                // Probably an edge closed earlier...
                return;
            }

            se.ReceivedPacketEvent(payload);
        }
コード例 #5
0
    public void Test() {
      SubringTransportAddress sta =new SubringTransportAddress(
          new AHAddress(Base32.Decode("CADSL6GVVBM6V442CETP4JTEAWACLC5A")),
          "ns.ns0.ns1");
      string ta_string = "brunet.subring://CADSL6GVVBM6V442CETP4JTEAWACLC5A.ns.ns0.ns1";
      TransportAddress ta = TransportAddressFactory.CreateInstance(ta_string);
      Assert.AreEqual(ta, sta, "TA == STA -- 1");

      ta_string = "brunet.subring://CADSL6GVVBM6V442CETP4JTEAWACLC5A.ns.ns0.ns1/";
      ta = TransportAddressFactory.CreateInstance(ta_string);
      Assert.AreEqual(ta, sta, "TA == STA -- 2");
    }
コード例 #6
0
    /// <summary>Where data packets prepended with a prepended subring come.
    /// Here we receive data as well as create new SubringEdges.</summary>
    public void HandleData(MemBlock data, ISender return_path, object state)
    {
      AHSender from = return_path as AHSender;
      if(from == null) {
        return;
      }

      AHAddress target = (AHAddress) from.Destination;
      MemBlock payload;
      int local_id, remote_id;
      _it.Parse(data, out payload, out local_id , out remote_id);

      IIdentifierPair ip;
      SubringEdge se;

      if(_it.TryGet(local_id, remote_id, out ip)) {
        se = ip as SubringEdge;
      } else if(local_id == 0) {
        if(!from.Node.Realm.Equals(_shared_node.Realm)) {
          // We don't have matching realms
          return;
        }
        var rem_sta = new SubringTransportAddress(target, from.Node.Realm);
        se = new SubringEdge(_local_ta, rem_sta, true, from, _ptype);
        _it.Add(se);
        se.RemoteID = remote_id;
        se.CloseEvent += CloseHandler;
        SendEdgeEvent(se);
      } else {
        // Probably an edge closed earlier...
        return;
      }

      se.ReceivedPacketEvent(payload);
    }