public virtual void AddEdgeListener(EdgeListener el) { /* The EdgeFactory needs to be made aware of all EdgeListeners */ _edge_factory.AddListener(el); _edgelistener_list.Add(el); /** * It is ESSENTIAL that the EdgeEvent of EdgeListener objects * be connected to the EdgeHandler method of ConnectionPacketHandler */ el.EdgeEvent += this.EdgeHandler; el.EdgeCloseRequestEvent += delegate(object elsender, EventArgs args) { EdgeCloseRequestArgs ecra = (EdgeCloseRequestArgs)args; Close(ecra.Edge); }; }
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 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); } }