Beispiel #1
0
        void ReadDataCallback(IAsyncResult ar)
        {
            WebReqState rs   = ar.AsyncState as WebReqState;
            int         read = rs.m_OrginalStream.EndRead(ar);

            if (read > 0)
            {
                rs.m_FileStream.Write(rs.m_Buffer, 0, read);
                rs.m_FileStream.Flush();
                rs.m_OrginalStream.BeginRead(rs.m_Buffer, 0, WebReqState.m_BufferSize, new AsyncCallback(ReadDataCallback), rs);
            }
            else
            {
                rs.m_FileStream.Close();
                rs.m_OrginalStream.Close();
                rs.m_WebResponse.Close();
                DebugMod.Log("http download url finish" + m_Url);
            }
        }
Beispiel #2
0
        void ResponseCallback(IAsyncResult ar)
        {
            HttpWebRequest req = ar.AsyncState as HttpWebRequest;

            if (req == null)
            {
                return;
            }
            HttpWebResponse resp = req.EndGetResponse(ar) as HttpWebResponse;

            if (resp.StatusCode != HttpStatusCode.OK)
            {
                resp.Close();
                DebugMod.LogError("http error:" + resp.StatusCode);
                return;
            }
            WebReqState st = new WebReqState(m_SavePath);

            st.m_WebResponse = resp;
            Stream responseStream = resp.GetResponseStream();

            st.m_OrginalStream = responseStream;
            responseStream.BeginRead(st.m_Buffer, 0, WebReqState.m_BufferSize, new AsyncCallback(ReadDataCallback), st);
        }
Beispiel #3
0
 void ResponseCallback(IAsyncResult ar)
 {
     HttpWebRequest req = ar.AsyncState as HttpWebRequest;
     if (req == null) return;
     HttpWebResponse resp = req.EndGetResponse(ar) as HttpWebResponse;
     if (resp.StatusCode != HttpStatusCode.OK)
     {
         resp.Close();
         DebugMod.LogError("http error:" + resp.StatusCode);
         return;
     }
     WebReqState st = new WebReqState(m_SavePath);
     st.m_WebResponse = resp;
     Stream responseStream = resp.GetResponseStream();
     st.m_OrginalStream = responseStream;
     responseStream.BeginRead(st.m_Buffer, 0, WebReqState.m_BufferSize, new AsyncCallback(ReadDataCallback), st);
 }