예제 #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 ();
        }
        public void TestStart()
        {
            ReaderWriterTest = new ReaderWriter ();

            Thread releaseTask = new Thread(AquireTokenReadCap);
            Thread releaseTask1 = new Thread(AquireTokenReadCap);
            Thread releaseTask2 = new Thread(AquireTokenWriteCap);
            Thread releaseTask3 = new Thread(AquireTokenWriteCap);
            Thread releaseTask4 = new Thread(AquireTokenReadCap);
            Thread releaseTask5 = new Thread(AquireTokenReadCap);
            Thread releaseTask6 = new Thread(AquireTokenWriteCap);
            Thread releaseTask7 = new Thread(AquireTokenWriteCap);
            releaseTask.Start();
            releaseTask1.Start ();
            releaseTask2.Start();
            releaseTask3.Start();
            Thread.Sleep (10000);
            releaseTask4.Start();
            releaseTask5.Start();
            releaseTask6.Start ();
            releaseTask7.Start();
        }