This commit is contained in:
2023-10-05 17:56:04 +09:00
parent bce6521e43
commit a3a0cc201b
7 changed files with 279 additions and 244 deletions

View File

@@ -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);