update
This commit is contained in:
@@ -20,23 +20,33 @@ namespace ConsoleApp.TelnetSamples
|
||||
try
|
||||
{
|
||||
_client.MessageCallback += On_Receive;
|
||||
_client.ErrorCallback += On_ErrorCallback;
|
||||
_client.Connect(ip, port);
|
||||
|
||||
while (true)
|
||||
{
|
||||
string command = Console.ReadLine();
|
||||
string command = Console.ReadLine().ToLower();
|
||||
if (command == "quit" || command == "exit")
|
||||
break;
|
||||
|
||||
_client.SendCommand(command);
|
||||
else if (command == "disconnect" || command == "disconn")
|
||||
_client.Close();
|
||||
else if (command == "connect" || command == "conn")
|
||||
_client.Connect(ip, port);
|
||||
else
|
||||
_client.SendCommand(command);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
Console.WriteLine($"[ERR] {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void On_ErrorCallback(object? sender, Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
|
||||
private void On_Receive(object? sender, string e)
|
||||
{
|
||||
Console.Write(e);
|
||||
|
Reference in New Issue
Block a user