Esempio n. 1
0
 public void Register(TrackerGetRegistrant registrant)
 {
     context.Queue.Add(() =>
     {
         context.Collection.Add(registrant);
     });
 }
Esempio n. 2
0
 public void Add(TrackerGetRegistrant registrant)
 {
     entries.Add(new TrackerGetEntry
     {
         Request = registrant,
         Next    = DateTime.Now
     });
 }
Esempio n. 3
0
 public static void AppendPort(this StringBuilder builder, TrackerGetRegistrant request)
 {
     if (request.Port > 0 && request.Port < 65535)
     {
         builder.Append("&port=");
         builder.Append(request.Port);
     }
 }
Esempio n. 4
0
 public void Announce(TrackerGetRegistrant request, Action <TimeSpan> callback)
 {
     context.Http.Register(new TrackerGetHttpRegistrant
     {
         Address  = address,
         Request  = request,
         Callback = callback
     });
 }
Esempio n. 5
0
 public void Announce(TrackerGetRegistrant request, Action <TimeSpan> callback)
 {
     context.Udp.Register(new TrackerGetUdpRegistrant
     {
         Host     = host,
         Port     = port,
         Request  = request,
         Callback = callback
     });
 }
Esempio n. 6
0
        public static void AppendEvent(this StringBuilder builder, TrackerGetRegistrant request)
        {
            switch (request.Event)
            {
            case TrackerGetEvent.Started:
                builder.Append("&event=started");
                break;

            case TrackerGetEvent.Stopped:
                builder.Append("&event=stopped");
                break;

            case TrackerGetEvent.Completed:
                builder.Append("&event=completed");
                break;
            }
        }
Esempio n. 7
0
        public static void AppendProgress(this StringBuilder builder, TrackerGetRegistrant request)
        {
            if (request.Progress?.Downloaded >= 0)
            {
                builder.Append("&downloaded=");
                builder.Append(request.Progress.Downloaded);
            }

            if (request.Progress?.Uploaded >= 0)
            {
                builder.Append("&uploaded=");
                builder.Append(request.Progress.Uploaded);
            }

            if (request.Progress?.Left >= 0)
            {
                builder.Append("&left=");
                builder.Append(request.Progress.Left);
            }
        }