Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            Console.WriteLine ("MyATM Server - Signed off by Andrew As Active Object - Signed off as Application.");
            int test = 0;
            bool debug = false; //To allow Prompts on the Server set this to true
            try
            {
                Console.WriteLine("\n\nInput: MyATM Server\n 0 - DEBUG = TRUE \t|\n 1 - DEBUG = FALSE \t|\n");
                test = int.Parse(Console.ReadLine());
                if(test == 0)
                {
                    debug = true;
                    Console.WriteLine("Debug is set to true - You will see the Server program checking items");
                }
                else if(test == 1)
                {
                    debug = false;
                    Console.WriteLine("Debug is set to False - You will NOT see the Server program checking items");
                }
                else
                {
                    Console.WriteLine("Exiting Program");
                    Thread.Sleep(5000);
                    System.Environment.Exit(1);
                }
                Console.WriteLine("\n\n");
            }
            catch (Exception)
            {
                Console.WriteLine("Unknown Input - Exiting in 5s");
                Thread.Sleep(5000);
                System.Environment.Exit(1);
            }
            //Input to allow Connection Over Putty
                ArrayList m_workerSocketList = ArrayList.Synchronized(new ArrayList());
                List<Account> Accounts = new List<Account>();
                char[] delimiterChars = { ',', '.' };
                int m_clientCount = 0;
                Socket m_mainSocket = null;
                AsyncCallback pfnWorkerCallBack = null;
            //End Connection Variables

            //Channels Used
                Channel<String> CapInToProcingMess = new Channel<String> ();
                Channel<String> OutputToClient = new Channel<String>();
            //End Channel Used
            //Reader Writer for account Editing
                ReaderWriter AccountManager = new ReaderWriter();

            //Active Objects Used
                ProcessMessage Logic = new ProcessMessage(CapInToProcingMess, OutputToClient,Accounts, delimiterChars, debug,AccountManager);
                ClientListener WaitingForClient = new ClientListener(CapInToProcingMess, m_workerSocketList, m_clientCount, m_mainSocket, pfnWorkerCallBack);
                OutputMessage Feedback = new OutputMessage(OutputToClient, m_workerSocketList, delimiterChars);

            //Start Active Objects
            WaitingForClient.Start ();
            Logic.Start ();
            Feedback.Start ();
        }