Exemplo n.º 1
0
        private void connection_SegmentRequested(object sender, HyperSegmentRequestEventArgs e)
        {
            //Logger.Info("Requested {0} {1}", e.Task.Length == -1 ? "file check" : "segment", e.Task.Path);

            var task = e.Task;

            task.Session = this;

            if (task.Length >= 0)
            {
                SegmentReqPerSecond.Update(1);
                task.Buffer = HyperDownloadManager.SegmentsPool.UseObject();
            }
            else
            {
                FileCheckReqPerSecond.Update(1);
            }

            var storage = _server.Storage.ResolveStorage(task.Path);

            if (storage == null)
            {
                if (task.IsFileCheck)
                {
                    task.FileLength = -1;
                    Logger.Trace("Task chk file is not found {0}", task.Token);
                    task.Done();
                }
                else
                {
                    Logger.Error("Can't resolve storage for {0}", task.Path);
                }
                return;
            }

            storage.EnqueueTask(task);
        }
Exemplo n.º 2
0
 protected virtual void OnSegmentRequested(HyperSegmentRequestEventArgs e)
 {
     SegmentRequested?.Invoke(this, e);
 }