public static bool resumeTorrent(string hash) { log.Trace("requested resume({0})", hash); Core.TorrentHandle th = getTorrentHandle(hash); th.resume(); return(th.status().paused == true); }
private static void OnTorrentAddAlert(Core.torrent_added_alert a) { Core.TorrentHandle th = a.handle; if (TorrentHandles.TryAdd(th.info_hash().ToString(), th)) { using (Core.TorrentStatus ts = th.status()) { var stat = "Paused"; if (!ts.paused) { stat = Utils.GiveMeStateFromEnum(ts.state); } var evnt = new EventsArgs.OnTorrentAddedEventArgs { Hash = th.info_hash().ToString(), Name = ts.name, Progress = ts.progress, QueuePosition = ts.queue_position, Status = stat }; //log.Debug("torrent added: name {0}; status {1}; hash {2}", ts.name, ts.state.ToString(), ts.info_hash.ToString()); // notify web that a new id must be requested via webapi if (webServer != null) { var context = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <www.SignalRHub>(); context.Clients.All.notifyTorrentAdded(evnt.Hash); } TorrentAdded?.Invoke(null, evnt); } } }
private void CountHavePieces() { var all_pieces = _torrentHandle.status().pieces; for (int i = starting_point; i < end_piece; i++) { if (!all_pieces.op_Subscript(i)) { last_have_piece = starting_point + i; num_have_pieces = i; } } }
public static List <Models.TorrentStatus> getTorrentStatusList() { _dispatcherTimer.Stop(); _sessionStatusDispatcherTimer.Stop(); List <Models.TorrentStatus> thl = new List <Models.TorrentStatus>(); foreach (KeyValuePair <string, Core.TorrentHandle> item in TorrentHandles) { Core.TorrentHandle th = item.Value; thl.Add(new Models.TorrentStatus(th.status()));// Models.TorrentHandle(item.Value)); } _dispatcherTimer.Start(); _sessionStatusDispatcherTimer.Start(); return(thl); }