public WrapperEdgeListener(EdgeListener el) {
   _sync = new object();
   lock(_sync) {
     _el = el;
     _el.EdgeEvent += HandleEdgeEvent;
     _el.EdgeCloseRequestEvent += HandleEdgeCloseRequestEvent;
     _edge_to_wrapper_edge = new Dictionary<Edge, WrapperEdge>(); 
     _edge_to_ecw = new  Dictionary<Edge, EdgeCreationWrapper>();
   }
 }
Пример #2
0
 /**
  * This creates Edges of a given type
  */
 public void CreateEdgeTo(TransportAddress destination,
                          EdgeListener.EdgeCreationCallback ecb)
 {
   TransportAddress.TAType t = destination.TransportAddressType;
   if( _el_map.Contains( t ) ) {
     EdgeListener el = (EdgeListener)_el_map[ t ];
     el.CreateEdgeTo( destination, ecb );
   }
   else {
     ecb(false, null, new EdgeException("No EdgeListener for TA type: " +
                                        t.ToString() ) );
   }
 }
Пример #3
0
    public static void Main(string[] args)
    {
      if (args.Length < 3) {
        Console.WriteLine("Usage: edgetester.exe " +
                          "[client|server] [tcp|udp|function] port " +
                          "localhost|qubit|cantor|starsky|behnam|kupka)");
        return;
      }

      if( args.Length >= 5) {
        delay = Int32.Parse(args[4]);
      }

      EdgeFactory ef = new EdgeFactory();
      int port = System.Int16.Parse(args[2]);

      _threads = ArrayList.Synchronized(new ArrayList());
      EdgeListener el = null;
      if( args[1] == "function" ) {
        //This is a special case, it only works in one thread
        el = new FunctionEdgeListener(port);
        el.EdgeEvent += new EventHandler(HandleEdge);
        //Start listening:
        el.Start();
        ef.AddListener(el);
        el.CreateEdgeTo(
         TransportAddressFactory.CreateInstance("brunet.function://localhost:" + port),
          ClientLoop);
      }
      else if (args[0] == "server") {
        if (args[1] == "tcp") {
          el = new TcpEdgeListener(port);
        }
        else if (args[1] == "udp") {
          el = new UdpEdgeListener(port);
        }
        else {
          el = null;
        }
        el.EdgeEvent += new EventHandler(HandleEdge);
//Start listening:
        el.Start();
        _el = el;
        Console.WriteLine("Press Q to quit");
        Console.ReadLine();
        el.Stop();
      }
      else if (args[0] == "client") {
        TransportAddress ta = null;
        if (args[1] == "tcp") {
          el = new TcpEdgeListener(port + 1);
        }
        else if (args[1] == "udp") {
          el = new UdpEdgeListener(port + 1);
        }
        else {
          el = null;
        }
        ef.AddListener(el);
        _el = el;
        string uri = "brunet." + args[1] + "://" + NameToIP(args[3]) + ":" + port;
        ta = TransportAddressFactory.CreateInstance(uri);
        System.Console.WriteLine("Making edge to {0}\n", ta.ToString());
        el.Start();
        ef.CreateEdgeTo(ta, ClientLoop);
      }
    }
 public SecureEdgeListener(EdgeListener el, SecurityOverlord so): base(el) {
   _so = so;
   _so.AnnounceSA += AnnounceSA;
 }
 public EdgeCreationWrapper(TransportAddress ta, EdgeListener.EdgeCreationCallback ecb,
     Edge edge, WrapperEdgeListener parent)
 {
   ExternalECB = ecb;
   TA = ta;
   Parent = parent;
   _edge = edge;
   _called = 0;
 }
Пример #6
0
 /**
  * NOTE: This should only be called by the Node that
  * owns this EdgeFactory.  DO NOT ADD EdgeListener objects
  * to the EdgeFactory.  Add them through the Node, and it
  * will add them to its EdgeFactory.
  * @see Node
  * 
  * EdgeListener objects actually make the edges of a given
  * type.  In order to make an Edge of a given type, you need
  * to register an EdgeListener to do that job.
  */
 public void AddListener(EdgeListener el)
 {
   _el_map[ el.TAType ] = el;
 }