Provides a Wrapper for edges, this allows us to control input, output, and state of the edge. This class is thread-safe.
Inheritance: Edge, IDataHandler
Ejemplo n.º 1
0
        ///<summary>This is called when one of our edges closes.  This handles
        ///removing the state from the EdgeListener as necessary.</summary>
        protected void EdgeClose(object o, EventArgs ea)
        {
            Edge e = o as Edge;

            if (e == null)
            {
                throw new Exception("Needs to be an Edge");
            }

            EdgeCreationWrapper ecw = null;
            WrapperEdge         we  = null;

            lock (_sync) {
                if (_edge_to_ecw.ContainsKey(e))
                {
                    ecw = _edge_to_ecw[e];
                    _edge_to_ecw.Remove(e);
                }
                else if (_edge_to_wrapper_edge.ContainsKey(e))
                {
                    we = _edge_to_wrapper_edge[e];
                    _edge_to_wrapper_edge.Remove(e);
                }
            }

            if (ecw != null)
            {
                ecw.CreationCallback(false, null, new EdgeException("Close on unwrapped edge!"));
            }
            else if (we != null)
            {
                we.Close();
            }
        }
Ejemplo n.º 2
0
        ///<summary>When the edge is finally wrapped, this is called to finalize
        ///the adding of the edge to the edgelistner.</summary>
        protected void Finalize(WrapperEdge wedge)
        {
            EdgeCreationWrapper ecw = null;

            lock (_sync) {
                if (_edge_to_ecw.ContainsKey(wedge.WrappedEdge))
                {
                    ecw = _edge_to_ecw[wedge.WrappedEdge];
                    _edge_to_ecw.Remove(wedge.WrappedEdge);
                    _edge_to_wrapper_edge[wedge.WrappedEdge] = wedge;
                }
                else
                {
                    throw new Exception("No record of edge");
                }
            }

            // if ecw is null, that means someone else failed before we announced
            // furthermore, we now have a wedge that needs to be manually closed!
            if (ecw != null)
            {
                ecw.CreationCallback(true, wedge, null);
            }
            else
            {
                wedge.Close();
            }
        }
Ejemplo n.º 3
0
        ///<summary>This is passed tothe underlying EdgeListener.  By default we do
        ///nothing to this.</summary>
        public override void UpdateRemoteTAs(IList list, Edge e, TransportAddress ta)
        {
            WrapperEdge edge = e as WrapperEdge;

            _el.UpdateRemoteTAs(list, edge.WrappedEdge, ta);
        }
Ejemplo n.º 4
0
        ///<summary>This method is usd to wrap the edge.</summary>
        protected virtual void WrapEdge(Edge edge)
        {
            WrapperEdge wedge = new WrapperEdge(edge);

            Finalize(wedge);
        }
Ejemplo n.º 5
0
        ///<summary>This is passed tothe underlying EdgeListener.  By default we do
        ///nothing to this.</summary>
        public override void UpdateLocalTAs(Edge e, TransportAddress ta)
        {
            WrapperEdge edge = e as WrapperEdge;

            _el.UpdateLocalTAs(edge.WrappedEdge, ta);
        }