public static async Task SeedAsync(string destination, string metaDest, FileHash hash, string tracker, NotificationCallback callback) { using (SwarmClient client = new SwarmClient()) { Notification notification; SwarmSession session = await client.ConnectAsync(hash, tracker); session.Seed(destination, metaDest); while (true) { notification = await session.NextAsync(); callback?.Invoke(notification); } } }
public static async Task DownloadAsync(string destination, string metaDest, FileHash hash, string tracker, NotificationCallback callback) { using (SwarmClient client = new SwarmClient()) { Notification notification; SwarmSession session = await client.ConnectAsync(hash, tracker); session.Download(destination, metaDest); while (true) { notification = await session.NextAsync(); callback?.Invoke(notification); if (notification.Type == NotificationType.DataCompleted) { break; } } } }