Exemplo n.º 1
0
        public async Task CancelAll(ResultDelegateBoolean cancelAllResultHandler)
        {
            try
            {
                CancelAllResultHandler = cancelAllResultHandler;

                List <JsonRequest.MultiCalls> multiCalls = new List <JsonRequest.MultiCalls>();
                foreach (DownloadItem downloadItem in _downloadItems)
                {
                    multiCalls.Add(new JsonRequest.MultiCalls("aria2.remove", $"\"{downloadItem.GetGid}\""));
                }
                String request = new JsonRequest("CancelAll", multiCalls.ToArray()).ToJson();
                await SocketSend(request);
            }
            catch (Exception e)
            {
                CancelAllResultHandler?.Invoke(false);
                ExceptionHelper.ShowErrorMsg("CancelAll", e);
            }
        }
Exemplo n.º 2
0
        public async Task Init(ResultDelegateBoolean initResultHandler, ResultDelegateBoolean initOnStartHandler, ResultDelegateStringString initOnCompleteHandler)
        {
            InitResultHandler     = initResultHandler;
            InitOnStartHandler    = initOnStartHandler;
            InitOnCompleteHandler = initOnCompleteHandler;

            if (!IsAriaOn())
            {
                await StartServer();
            }

            Boolean connection = await ConnectServer();

            if (connection)
            {
                SocketReceive();
                await GetDownloadHistory();
            }
            else
            {
                InitResultHandler?.Invoke(false);
            }
        }