//=============================================================== static void ServerWorkMode() { server = new MSConnectionServerTest(); bool ret = server.BuildServer(Name, (int)numberOfMessages, mode); if (ret == false) { Console.WriteLine("Server Creation error!"); Environment.Exit(0); } while (true) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("exit - terminate process"); Console.ForegroundColor = ConsoleColor.White; string word = Console.ReadLine(); if (word == "exit") { server.Dispose(); Environment.Exit(0); } } }
//=============================================================== static void Main(string[] args) { if ( (args.Length == 0) || (args.Length > 5) || (args[0] != "/wm:debug") && (args[0] != "/wm:server") && (args[0] != "/wm:client") ) { Help(); } ReadParameters(args); Console.WriteLine("{0} {1}\n{2} {3}\n {4} {5}\n {6} {7}\n {8} {9}\n {10} {11}\n {12} {13}\n", "Work mode: ", WorkMode, " Connection mode: ", mode, " Print: ", Global.PrintFlag, " numberOfMessages: ", numberOfMessages, " Mailslot name: ", Name, " client_name: ", client_name, " server_addr: ", server_address); if (WorkMode == "server") { ServerWorkMode(); } if (WorkMode == "debug") { DebugWorkMode(); } client = new MSConnectionCS.MSConnectionClient(); client.BuildClient(server_address, Name, client_name, mode); while (true) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("0 - to send msg with id = STRING_MESSAGE"); Console.WriteLine("1 - to send msg with id = MSG_COMPUTER_ORDER"); Console.WriteLine("2 - to send msg with id = MSG_MOBILE_ORDER"); Console.WriteLine("exit - terminate process"); Console.ForegroundColor = ConsoleColor.White; string cmd = Console.ReadLine(); switch (cmd) { case "0": { Console.Write("string to send: "); string word = Console.ReadLine(); STRING_MESSAGE sm = new STRING_MESSAGE(); sm.message = client.StringToByte(word, 200, Encoding.ASCII); client.SendMsg <STRING_MESSAGE>((uint)MESSAGE_ID.MSG_COMPUTER_STRING_MSG, sm); break; } case "1": { ALL_IN_ONE_COMPUTER aoc = new ALL_IN_ONE_COMPUTER(); aoc.Display = 22; aoc.memory = 8; aoc.SSD = 256; aoc.os = OPERATING_SYSTEM_COMPUTER.Linux; aoc.Customer = client.StringToByte("Tom", 20, Encoding.ASCII); aoc.Manufacturer = client.StringToByte("Hewlett Paccard", 20, Encoding.ASCII); aoc.CPU = client.StringToByte("Intel", 20, Encoding.ASCII); client.SendMsg <ALL_IN_ONE_COMPUTER>((uint)MESSAGE_ID.MSG_COMPUTER_ORDER, aoc); break; } case "2": { MOBILE_PHONE mp = new MOBILE_PHONE(); mp.Customer = client.StringToByte("Bob", 20, Encoding.ASCII); mp.Display = 6; mp.Manufacturer = MANUFACTURER.Samsung; mp.memory = 512; mp.osm = OPERATING_SYSTEM_MOBILE.Android; client.SendMsg <MOBILE_PHONE>((uint)MESSAGE_ID.MSG_MOBILE_ORDER, mp); break; } case "exit": if (client != null) { client.Dispose(); } if (server != null) { server.Dispose(); } Environment.Exit(0); break; default: break; } } } // static void Main...