コード例 #1
0
        protected override void OnPostProcessing(uint hint, ulong data)
        {
            CContext      ctx = null;
            CClientSocket cs  = AttachedClientSocket;

            lock (m_csFile) {
                if (m_vContext.Count > 0)
                {
                    CContext context = m_vContext[0];
                    if (context.Uploading)
                    {
                        OpenLocalRead(context);
                    }
                    else
                    {
                        OpenLocalWrite(context);
                    }
                    DAsyncResultHandler    rh = null;
                    DOnExceptionFromServer se = null;
                    if (context.HasError)
                    {
                        ctx = context;
                    }
                    else if (context.Uploading)
                    {
                        if (!SendRequest(idUpload, context.FilePath, context.Flags, context.FileSize, rh, context.Discarded, se))
                        {
                            ctx             = context;
                            context.ErrCode = cs.ErrorCode;
                            context.ErrMsg  = cs.ErrorMsg;
                        }
                    }
                    else
                    {
                        if (!SendRequest(idDownload, context.LocalFile, context.FilePath, context.Flags, context.InitSize, rh, context.Discarded, se))
                        {
                            ctx             = context;
                            context.ErrCode = cs.ErrorCode;
                            context.ErrMsg  = cs.ErrorMsg;
                        }
                    }
                }
            }
            if (ctx == null)
            {
                return;
            }
            if (ctx.Download != null)
            {
                ctx.Download(this, ctx.ErrCode, ctx.ErrMsg);
            }
            lock (m_csFile) {
                CloseFile(m_vContext.RemoveFromFront());
                if (m_vContext.Count > 0)
                {
                    ClientCoreLoader.PostProcessing(AttachedClientSocket.Handle, 0, 0);
                    AttachedClientSocket.DoEcho(); //make sure WaitAll works correctly
                }
            }
        }