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