示例#1
0
        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");
        }
示例#2
0
        static void Main(string[] args)
        {
            /** il faut mettre en lien le flow et la tache peut etre avec write **/
            Flow flow = new Flow();

            Console.WriteLine("Flow OK");


            //Com creator
            ComCreator comCreator = new ComCreator(2, flow);

            Console.WriteLine("ComCreator OK");


            //Flow Decorator
            FlowDecorator flowDecorator = new FlowDecorator(flow);

            Console.WriteLine("FlowDecorator OK");

            //Command Executor
            TaskCommandExecutor commandExecutor = new TaskCommandExecutor(comCreator);

            Console.WriteLine("Executor OK");


            //création de 3 taches
            TaskCommand <String> tache1 = new TaskCommand <string>("Message1", comCreator);

            Console.WriteLine("Tache1 OK");
            TaskCommand <String> tache2 = new TaskCommand <string>("Message2", comCreator);

            Console.WriteLine("Tache2 OK");
            TaskCommand <String> tache3 = new TaskCommand <string>("Message3", comCreator);

            Console.WriteLine("Tache3 OK");

            Console.ReadLine();
        }
示例#3
0
        public void setFluxProperty(Property property)
        {
            this.property = property;

            if (property.Equals(Property.CLEAR))
            {
                Console.WriteLine("*******Propriété d'envoi : CLEAR -------> Création decorator CLEAR flow");
                Console.WriteLine();
                _flowDecorator = new ClearDecorator(this.flow);
            }

            if (property.Equals(Property.COMPRESSED))
            {
                Console.WriteLine("*******Propriété d'envoi : COMPRESSED -------> Création decorator COMPRESSED flow");
                Console.WriteLine();
                _flowDecorator = new CompDecorator(this.flow);
            }
            if (property.Equals(Property.ENCRYPTED))
            {
                Console.WriteLine("*******Propriété d'envoi : ENCRYPTED -------> Création decorator ENCRYPTED flow");
                Console.WriteLine();
                _flowDecorator = new EncDecorator(this.flow);
            }
        }