Exemplo n.º 1
0
 public Bot(string name, string password, string ip, int port)
 {
     Name = name;
     // We need to hash the password before we can use it to login.
     _passwordhash = BashTcpClient.Hash(password);
     IP = ip;
     Port = port;
     Client = new BashTcpClient();
     PingTimer.Elapsed += PingTimerOnElapsed;
 }
Exemplo n.º 2
0
 // The asynchronous read loop.
 // This handles the reading and parsing of all commands
 //  from the connected server.
 private async void ReadLoop()
 {
     while (Client.Connected)
     {
         // Asyncronously read line
         var line = await Client.Reader.ReadLineAsync();
         if (line != null) // If the line is null that means the connection has ended.
         {
             // Convert the line to a BashCommand and then process it
             ProcessLine(BashCommandParser.Parse(line));
         }
         else
         {
             // If we disconnect, try to reconnect!
             Console.WriteLine("Disconnected, Reconnecting..");
             Client = new BashTcpClient();
             Login();
         }
     }
 }