Exemplo n.º 1
0
 ///<summary>Creates a new WrapperEdge.<summary>
 ///<param name="edge">The edge to wrap.</param>
 ///<param name="SubscribeToEdge">Should this subscribe to the edge.</param>
 public WrapperEdge(Edge edge, bool SubscribeToEdge)
 {
     _edge = edge;
     if (SubscribeToEdge)
     {
         _edge.Subscribe(this, null);
     }
 }
Exemplo n.º 2
0
            public void HandleEC(bool succ, Edge e, Exception x)
            {
                if (!succ)
                {
                    ECB(false, null, x);
                    return;
                }
                else if (_root)
                {
                    Interlocked.Increment(ref _pel._count);
                    e.CloseEvent += _pel.CloseHandler;
                    ECB(succ, e, x);
                    return;
                }

                /*
                 * Got the underlying Edge, now do the path protocol
                 */
                Channel results = new Channel(1);

                results.CloseEvent += delegate(object q, EventArgs args) {
                    try {
                        RpcResult res = (RpcResult)results.Dequeue();
                        object    o   = res.Result;
                        if (o is Exception)
                        {
                            throw (o as Exception);
                        }
                    } catch (Exception cx) {
                        e.Close();
                        ECB(false, null, cx);
                        return;
                    }

                    //If we get here, everything looks good:
                    PathEdge pe = new PathEdge(_pel._pem, e, LocalPath, RemotePath);
                    //Start sending e's packets into pe
                    pe.Subscribe();
                    pe.CloseEvent += _pel.CloseHandler;
                    Interlocked.Increment(ref _pel._count);
                    ECB(true, pe, null);
                };

                //Make sure we hear the packets on this edge:
                e.Subscribe(_pel._pem, null);
                //Now make the rpc call:
                _pel._pem.Rpc.Invoke(e, results, "sys:pathing.create", LocalPath, RemotePath);
            }
Exemplo n.º 3
0
        /** Watch this incoming Edge
         */
        protected void HandleEdge(object newedge, System.EventArgs args)
        {
            Edge e = (Edge)newedge;

            try {
                e.CloseEvent += this.HandleEdgeClose;
                e.Subscribe(this, null);
                lock ( _sync ) {
                    _edges.Add(e);
                }
            }
            catch (Exception x) {
                //Didn't work out, make sure the edges is closed
                ProtocolLog.WriteIf(ProtocolLog.Pathing,
                                    String.Format("Closing ({0}) due to: {1}", e, x));
                e.Close();
            }
        }
Exemplo n.º 4
0
 public void Subscribe()
 {
     _e.Subscribe(this, null);
 }