static void Main(string[] args) { /************************ INITIALISATION API - PARAMETRES ********************/ Console.WriteLine("/************************ INITIALISATION API ********************/"); //construction : entrez les paramétres /* Parametre 1 = nombre threads * Parametre 2 = Protocole communication * Parametre 3 = propriété flux */ TypeCommunication typeCom = TypeCommunication.UDP; // enum UDP, TCP Property property = Property.COMPRESSED; // enum COMPRESSED, CLEAR, ENCRYPTED FluxBuilder builder = new FluxBuilder(3, typeCom, property); /************************ INITIALISATION API - CONSOLE ********************/ //création flow decorator FlowDecorator flowDecorator = builder.getResult(); // Création task executor TaskExecutor executor = new TaskExecutor(builder); flowDecorator.Executor = executor; //simulation de taches et de leur traitement int iterateurTaches = 0; Console.WriteLine("Press ESC key to stop simulation"); Console.WriteLine(); do { while (!Console.KeyAvailable) { SendMsgTask tacheX = new SendMsgTask("tache" + iterateurTaches); flowDecorator.send(new Flow(tacheX)); iterateurTaches++; Console.WriteLine("*********Nombre de taches courant : " + iterateurTaches); //on simule un laps de temps avant de recevoir d'autres atches Thread.Sleep(500); } } while (Console.ReadKey(true).Key != ConsoleKey.Escape); executor.Stop(); Console.WriteLine("Envoi des taches effectués"); }
public void setProtocol(TypeCommunication _typeCommunication) { this._typeCom = _typeCommunication; if (_typeCommunication.Equals(TypeCommunication.UDP)) { Console.WriteLine("*******Type de communication : UDP -------> Création flux UDP "); Console.WriteLine(); UDPFactory udpFactory = new UDPFactory(); this.flow = udpFactory.CreateFlux(); } if (_typeCommunication.Equals(TypeCommunication.TCP)) { Console.WriteLine("*******Type de communication : TCP -------> Création flux TCP "); Console.WriteLine(); TCPFactory tcpFactory = new TCPFactory(); this.flow = tcpFactory.CreateFlux(); } }
public FluxBuilder(int numThread, TypeCommunication typeCom, Property property) { setNumThread(numThread); setProtocol(typeCom); setFluxProperty(property); }