using System; namespace Sodao.FastSocket.SocketBase { /// /// packet /// public class Packet { #region Members /// /// get or set sent size. /// internal int SentSize = 0; /// /// get the packet created time /// public readonly DateTime CreatedTime = Utils.Date.UtcNow; /// /// get payload /// public readonly byte[] Payload; #endregion #region Constructors /// /// new /// /// /// payload is null. public Packet(byte[] payload) { this.Tag = ""; if (payload == null) throw new ArgumentNullException("payload"); this.Payload = payload; this.Tag = System.Text.Encoding.UTF8.GetString(payload); } #endregion #region Public Properties /// /// get or set tag object /// public object Tag { get; set; } #endregion #region Public Methods /// /// 获取一个值,该值指示当前packet是否已发送完毕. /// /// true表示已发送完毕 public bool IsSent() { return this.SentSize == this.Payload.Length; } #endregion } }