mirror of
https://github.com/Stone-Red-Code/HyperbolicDownloader.git
synced 2026-09-10 07:46:25 +02:00
Add list files remote command
This commit is contained in:
@@ -103,7 +103,6 @@ public class ApiManager
|
||||
}
|
||||
|
||||
SendNotificationMessageNewLine("Ports closed!", NotificationMessageType.Warning);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
public bool StartBroadcastListener()
|
||||
@@ -130,6 +129,7 @@ public class ApiManager
|
||||
networkClient.ListenTo<List<NetworkSocket>>("DiscoverAnswer", DiscoverAnswer);
|
||||
networkClient.ListenTo<string>("Message", ReciveMessage);
|
||||
networkClient.ListenTo<string>("HasFile", HasFile);
|
||||
networkClient.ListenTo<string>("GetFilesList", GetFileList);
|
||||
networkClient.StartListening(ApiConfiguration.PrivatePort);
|
||||
}
|
||||
catch (SocketException ex)
|
||||
@@ -223,6 +223,13 @@ public class ApiManager
|
||||
await recivedEventArgs.SendResponseAsync(FilesManager.Contains(recivedEventArgs.Data));
|
||||
}
|
||||
|
||||
private async void GetFileList(object? sender, MessageRecivedEventArgs<string> recivedEventArgs)
|
||||
{
|
||||
SendNotificationMessageNewLine($"{recivedEventArgs.IpAddress} > Requesting file list", NotificationMessageType.Log);
|
||||
|
||||
await recivedEventArgs.SendResponseAsync(FilesManager.ToList().Select(f => new HyperFileDto(f)).ToList());
|
||||
}
|
||||
|
||||
private void ReciveMessage(object? sender, MessageRecivedEventArgs<string> recivedEventArgs)
|
||||
{
|
||||
SendNotificationMessageNewLine($"Received \"{recivedEventArgs.Data}\" from {recivedEventArgs.IpAddress}.", NotificationMessageType.Info);
|
||||
|
||||
Reference in New Issue
Block a user