Exemplo n.º 1
0
        public void command(String commands)
        {
            if (commands.Equals(""))
            {
                return;
            }

            if (!(commands.StartsWith("Site")))
            {
                add_Message_List(commands);
            }

            String[] command = commands.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);

            switch (command[0])
            {
            case "Site":
                sitesT.Add(command[1], command[3]);
                puppet.addSite(command[1], command[3]);
                break;

            case "Process":
                if (command[3].Equals("BROKER") || command[3].Equals("broker"))
                {
                    add_Message_List("");
                    if (sitesT[command[5]].Equals("none"))
                    {
                        puppet.addBroker(command[1], command[5], command[7], "null");
                    }
                    else
                    {
                        puppet.addBroker(command[1], command[5], command[7], puppet.getParent(sitesT[command[5]]));
                    }
                }
                else if (command[3].Equals("SUBSCRIBER") || command[3].Equals("subscriber"))
                {
                    puppet.addSubscriber(command[1], command[5], command[7]);
                }
                else if (command[3].Equals("PUBLISHER") || command[3].Equals("publisher"))
                {
                    puppet.addPublisher(command[1], command[5], command[7]);
                }
                break;

            case "Subscriber":
                if (command[2].Equals("Subscribe"))
                {
                    puppet.subscribe(command[1], command[3]);
                }
                else if (command[2].Equals("Unsubscribe"))
                {
                    puppet.unsubscribe(command[1], command[3]);
                }
                break;

            case "Publisher":
                puppet.publish(command[1], command[3], command[5], command[7]);
                break;

            case "Status":
                puppet.status();
                break;

            case "Crash":
                puppet.crash(command[1]);
                break;

            case "Freeze":
                puppet.freeze(command[1]);
                break;

            case "Unfreeze":
                puppet.unfreeze(command[1]);
                break;

            case "Wait":
                Thread.Sleep(Int32.Parse(command[1]));
                break;

            case "RoutingPolicy":
                puppet.changePolicy(command[1]);
                break;

            case "Ordering":
                puppet.changeOrdering(command[1]);
                break;

            case "LoggingLevel":
                puppet.changeLogLvl(command[1]);
                break;
            }
        }