Holds the state information for a Subrings.
Наследование: Edge, IIdentifierPair
Пример #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
        /// <summary>Remove closed edges from the IdentifierTable</summary>
        protected void CloseHandler(object o, EventArgs ea)
        {
            SubringEdge se = o as SubringEdge;

            if (se != null)
            {
                _it.Remove(se.LocalID);
            }
        }
Пример #3
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);
        }
Пример #4
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);
      }
    }
Пример #5
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);
    }