Beispiel #1
0
        protected internal override void ReportError(TcpSession session, Exception e)
        {
            base.ReportError(session, e);

            //触发发生错误的事件
            async.EndAsyncOperationWithError(e);
        }
Beispiel #2
0
        protected override void OnReceivedData(TcpSession session, DataBlock dataBlock)
        {
            try
            {
                recvFile.Write(dataBlock.Buffer, dataBlock.ReadIndex, dataBlock.DataLength);
                recvFileLength += dataBlock.DataLength;
            }
            catch (System.Exception e)
            {
                AsyncHelper.EndAsyncOperationWithError(e);
            }

            if (recvFileLength > MaxLengthOfUpload)
            {
                AsyncHelper.EndAsyncOperationWithError(new NetException("upload file's length limit"));
            }

            dataBlock.Reset();
        }