Exemple #1
0
        /// <summary>
        /// 暂未测试,添加BT种子下载任务
        /// </summary>
        /// <param name="torrentStream">用于读取种子内容的流</param>
        public static string AddTorrent(Stream torrentStream, object id = null)
        {
            MemoryStream ms = new MemoryStream();

            torrentStream.CopyTo(ms);

            var torrent = Convert.ToBase64String(ms.ToArray());

            var token = new JsonRpcToken("aria2.addTorrent", id, torrent);

            return(s_instance.RawRemoteCall <string>(token));
            //return (string)JsonRpcHelper.RemoteCall(RPC_URL, token);
        }
Exemple #2
0
        /// <summary>
        /// 添加下载任务,返回值为新添加下载任务的GID
        /// GID可用于控制对应任务的开始,暂停,下载进度查询,插队下载等
        /// </summary>
        /// <param name="uris">
        /// 指向同一资源的HTTP/FTP/SFTP/BitTorrent URI数组.
        /// 当数组指的元素指向不同的资源时,添加下载任务将会失败.
        /// When adding BitTorrent Magnet URIs, uris must have only one element and it should be BitTorrent Magnet URI.
        /// </param>
        /// <param name="options">
        /// options is a struct and its members are pairs of option name and value.
        /// </param>
        /// <param name="position">
        /// If position is given, it must be an integer starting from 0.
        /// The new download will be inserted at position in the waiting queue.
        /// If position is omitted or position is larger than the current size of the queue, the new download is appended to the end of the queue.
        /// </param>
        /// <param name="id"></param>
        /// <returns>所添加任务的GID</returns>
        public static string AddUri(string[] uris, IDictionary <string, string> options = null, int position = -1, object id = null)
        {
            var token = new JsonRpcToken("aria2.addUri", id);

            if (options == null)
            {
                token.Params = new object[] { uris, new object() };
            }
            else if (position < 0)
            {
                token.Params = new object[] { uris, options };
            }
            else
            {
                token.Params = new object[] { uris, options, position };
            }
            return(s_instance.RawRemoteCall <string>(token));
            //return (string)JsonRpcHelper.RemoteCall(RPC_URL, token);
        }
Exemple #3
0
 private T RawRemoteCall <T>(JsonRpcToken token)
 {
     return((T)this.RawRemoteCall(token));
 }
Exemple #4
0
 private object RawRemoteCall(JsonRpcToken token)
 {
     return(JsonRpcHelper.RemoteCall(this.m_rpcUrl, token));
 }