Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        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;
                    }
                }
            }
        }