private void OnWebRequestAgentFailure(WebRequestAgent sender, string errorMessage) { //if (m_WebRequestFailureEventHandler != null) //{ // WebRequestFailureEventArgs webRequestFailureEventArgs = WebRequestFailureEventArgs.Create(sender.Task.SerialId, sender.Task.WebRequestUri, errorMessage, sender.Task.UserData); // m_WebRequestFailureEventHandler(this, webRequestFailureEventArgs); // ReferencePool.Release(webRequestFailureEventArgs); //} }
/// <summary> /// 获取所有 Web 请求任务的信息。 /// </summary> /// <returns>所有 Web 请求任务的信息。</returns> //public TaskInfo[] GetAllWebRequestInfos() //{ // return m_TaskPool.GetAllTaskInfos(); //} private void OnWebRequestAgentStart(WebRequestAgent sender) { //if (m_WebRequestStartEventHandler != null) //{ // WebRequestStartEventArgs webRequestStartEventArgs = WebRequestStartEventArgs.Create(sender.Task.SerialId, sender.Task.WebRequestUri, sender.Task.UserData); // m_WebRequestStartEventHandler(this, webRequestStartEventArgs); // ReferencePool.Release(webRequestStartEventArgs); //} }
private void OnWebRequestAgentSuccess(WebRequestAgent sender, byte[] webResponseBytes) { //if (m_WebRequestSuccessEventHandler != null) //{ // WebRequestSuccessEventArgs webRequestSuccessEventArgs = WebRequestSuccessEventArgs.Create(sender.Task.SerialId, sender.Task.WebRequestUri, webResponseBytes, sender.Task.UserData); // m_WebRequestSuccessEventHandler(this, webRequestSuccessEventArgs); // ReferencePool.Release(webRequestSuccessEventArgs); //} }
/// <summary> /// 增加 Web 请求代理辅助器。 /// </summary> /// <param name="webRequestAgentHelper">要增加的 Web 请求代理辅助器。</param> public void AddWebRequestAgentHelper(IWebRequestAgentHelper webRequestAgentHelper) { WebRequestAgent agent = new WebRequestAgent(webRequestAgentHelper); agent.WebRequestAgentStart += OnWebRequestAgentStart; agent.WebRequestAgentSuccess += OnWebRequestAgentSuccess; agent.WebRequestAgentFailure += OnWebRequestAgentFailure; m_TaskPool.AddAgent(agent); }