mirror of
https://github.com/Stone-Red-Code/HyperbolicDownloader.git
synced 2026-09-04 00:56:09 +02:00
Fix output of add host command
This commit is contained in:
@@ -148,9 +148,14 @@ public class HostCommands
|
||||
|
||||
if (recivedHosts is not null)
|
||||
{
|
||||
ApiManager.SendNotificationMessageNewLine($"Success! Added {recivedHosts.Count} new host(s).", NotificationMessageType.Success);
|
||||
hostsManager.AddRange(recivedHosts);
|
||||
hostsManager.Add(new NetworkSocket(ipAddress.ToString(), port, DateTime.Now));
|
||||
int newHosts = hostsManager.AddRange(recivedHosts);
|
||||
|
||||
if (hostsManager.Add(new NetworkSocket(ipAddress.ToString(), port, DateTime.Now)))
|
||||
{
|
||||
newHosts++;
|
||||
}
|
||||
|
||||
ApiManager.SendNotificationMessageNewLine($"Success! Added {newHosts} new host(s).", NotificationMessageType.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -10,23 +10,33 @@ public class HostsManager
|
||||
private List<NetworkSocket> hosts = new List<NetworkSocket>();
|
||||
public int Count => hosts.Count;
|
||||
|
||||
public void AddRange(IEnumerable<NetworkSocket> hosts)
|
||||
public int AddRange(IEnumerable<NetworkSocket> hosts)
|
||||
{
|
||||
int newHosts = 0;
|
||||
|
||||
foreach (NetworkSocket host in hosts)
|
||||
{
|
||||
Add(host);
|
||||
if (Add(host))
|
||||
{
|
||||
newHosts++;
|
||||
}
|
||||
}
|
||||
|
||||
SaveHosts();
|
||||
|
||||
return newHosts;
|
||||
}
|
||||
|
||||
public void Add(NetworkSocket host)
|
||||
public bool Add(NetworkSocket host)
|
||||
{
|
||||
if (!Contains(host))
|
||||
{
|
||||
hosts.Add(host);
|
||||
return true;
|
||||
}
|
||||
SaveHosts();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Remove(NetworkSocket host, bool forceRemove = false)
|
||||
|
||||
Reference in New Issue
Block a user