static void Main(string[] args)
    {
        ClientObject co = new ClientObject();
        string myIpAddress = co.GetClientIpAdress();

        HttpChannel chnl = new HttpChannel(null, new XmlRpcClientFormatterSinkProvider(), null);
        ChannelServices.RegisterChannel(chnl, false);

        _localProxy = XmlRpcHelper.Connect("localhost");

        _currentMasterUrl = _localProxy.getIpMaster(myIpAddress);
        _masterProxy = XmlRpcHelper.Connect(_currentMasterUrl);

        try
        {
            // ====== Begin client input ======
            string input;
            ClientUI clientUi = new ClientUI();

            do
            {
                clientUi.DisplayMainMenu(myIpAddress);
                input = Console.ReadLine();
                switch (input)
                {
                    case "1":
                        // Menu 1: Show master hashmap.
                        // localProxy.checkMasterStatus();

                        XmlRpcStruct masterMap = _masterProxy.getMachines(myIpAddress);

                        Dictionary<int, string> networkHashMap = Helper.ConvertObjToDict(masterMap);

                        Console.WriteLine("The Masternode hashmap");
                        foreach (KeyValuePair<int, string> networkNode in networkHashMap)
                        {
                            Console.WriteLine("Priority {0} : {1}", networkNode.Key, networkNode.Value);
                        }

                        Console.ReadKey();
                        break;

                    case "2":
                        // Menu 2: Show local hashmap.
                        // localProxy.checkMasterStatus();

                        XmlRpcStruct localMap = _localProxy.getMachines(myIpAddress);

                        Dictionary<int, string> localhostHashMap = Helper.ConvertObjToDict(localMap);

                        Console.WriteLine("The localnode hashmap");
                        foreach (KeyValuePair<int, string> localNode in localhostHashMap)
                        {
                            Console.WriteLine("Priority {0} : {1}", localNode.Key, localNode.Value);
                        }
                        Console.ReadKey();
                        break;

                    case "3":
                        // Menu 3: Get Master Ip.
                        //localProxy.checkMasterStatus();

                        string result = _localProxy.getIpMaster(myIpAddress);
                        Console.WriteLine("the masterNode is {0}", result);
                        Console.ReadKey();
                        break;

                    case "4":
                        //Menu 4: do election.
                        // masterProxy.checkMasterStatus();

                        Console.WriteLine("Election held!!!");

                        string newMaster = _localProxy.leaderElection(myIpAddress);
                        //string newMasterIp = localProxy.getIpMaster(ipAddress);

                        Console.WriteLine("The new masternode is {0}", newMaster);
                        Console.ReadKey();
                        break;

                    case "5":
                        // Menu 5: Ricart Agrawala Exlusion.
                        StartMutualExclusion(false);
                        Console.ReadKey();
                        break;

                    case "6":
                        // Menu 6: Test Mutual Exclusion.
                        StartMutualExclusion(true);
                        Console.ReadKey();
                        break;

                    case "0":
                        // exit
                        break;

                    default:
                        Console.WriteLine("Invalid command. Please re-enter the command.");
                        Console.ReadKey();
                        break;
                }
            }
            while (input != "0");

            Console.WriteLine("Ending the client session.");
            Console.ReadKey();
        }
        catch (XmlRpcFaultException fex)
        {
            Console.WriteLine("Fault response {0} {1} {2}",
                fex.FaultCode, fex.FaultString, fex.Message);
            Console.ReadLine();
        }
        // ===========End of Client Input================
    }