Exemplo n.º 1
0
 public void Register(TrackerGetRegistrant registrant)
 {
     context.Queue.Add(() =>
     {
         context.Collection.Add(registrant);
     });
 }
Exemplo n.º 2
0
 public void Add(TrackerGetRegistrant registrant)
 {
     entries.Add(new TrackerGetEntry
     {
         Request = registrant,
         Next    = DateTime.Now
     });
 }
Exemplo 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);
     }
 }
Exemplo n.º 4
0
 public void Announce(TrackerGetRegistrant request, Action <TimeSpan> callback)
 {
     context.Http.Register(new TrackerGetHttpRegistrant
     {
         Address  = address,
         Request  = request,
         Callback = callback
     });
 }
Exemplo n.º 5
0
 public void Announce(TrackerGetRegistrant request, Action <TimeSpan> callback)
 {
     context.Udp.Register(new TrackerGetUdpRegistrant
     {
         Host     = host,
         Port     = port,
         Request  = request,
         Callback = callback
     });
 }
Exemplo 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;
            }
        }
Exemplo 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);
            }
        }