cs_elbot.TCPWrapper.ReconnectToServer C# (CSharp) Method

ReconnectToServer() public method

public ReconnectToServer ( ) : void
return void
        public void ReconnectToServer()
        {
            bool GotConnected = false;

            while (!GotConnected && !MainClass.tryingToConnect)
            {
                MainClass.tryingToConnect = true;
                TheLogger.Log("Trying to connect to server...");
                GotConnected = ConnectToServer();
                if (GotConnected == false)
                {
                    TheLogger.Log("... failed");
                    MainClass.tryingToConnect = false;
                    System.Threading.Thread.Sleep(10000);
                }
                else
                {
                    TheLogger.Log("... successful");
                    MainClass.tryingToConnect = false;
                }
            }
        }

Usage Example

Example #1
0
        public bool Interprete(string Command)
        {
            Command = Command.Trim();

            switch (Command.ToLower())
            {
            case "login":
                TheTCPWrapper.ReconnectToServer();
                break;

            case "logout":
                TheTCPWrapper.DisconnectFromServer();
                break;

            case "quit":
                TheMessageParser.FakePM("Console:\\>", "#say  ### GOING DOWN FOR MAINTENANCE ###");
                TheMessageParser.FakePM("Console:\\>", "#say #gm ### GOING DOWN FOR MAINTENANCE ###");
                System.Environment.Exit(0);
                break;

            default:
                if (Command.Length > 0)
                {
                    if (Command[0] == '#')
                    {
                        TheMessageParser.FakePM("Console:\\>", Command);
                    }
                }
                break;
            }

            return(true);
        }