public bool SendAsyncCompleted() { ActiveDateTime = DateTime.UtcNow; mSendAsync = false; SendBuffer.ClearFirstPacket(); //清除已发送的包 int offset = 0; int count = 0; if (SendBuffer.GetFirstPacket(ref offset, ref count)) { mSendAsync = true; // 设置发送的数据包 SendEventArgs.SetBuffer(SendBuffer.Buffer.Bytes, offset, count); return(AsyncNet.SendAsync(this)); } else { return(true); } }
public bool SendAsync(bool isFinished) { lock (sync) { if (!isFinished) { if (!isSending) { return(SendData()); } return(true); } else { ActiveDateTime = DateTime.UtcNow; isSending = false; SendBuffer.ClearFirstPacket(); //清除已发送的包 return(SendData()); } } }