using System; namespace UnityWebSocket { /// /// Represents the event data for the event. /// /// /// /// That event occurs when the WebSocket connection has been closed. /// /// /// If you would like to get the reason for the close, you should access /// the or property. /// /// public class CloseEventArgs : EventArgs { #region Internal Constructors internal CloseEventArgs() { } internal CloseEventArgs(ushort code) : this(code, null) { } internal CloseEventArgs(CloseStatusCode code) : this((ushort)code, null) { } internal CloseEventArgs(CloseStatusCode code, string reason) : this((ushort)code, reason) { } internal CloseEventArgs(ushort code, string reason) { Code = code; Reason = reason; } #endregion #region Public Properties /// /// Gets the status code for the close. /// /// /// A that represents the status code for the close if any. /// public ushort Code { get; private set; } /// /// Gets the reason for the close. /// /// /// A that represents the reason for the close if any. /// public string Reason { get; private set; } /// /// Gets a value indicating whether the connection has been closed cleanly. /// /// /// true if the connection has been closed cleanly; otherwise, false. /// public bool WasClean { get; internal set; } /// /// Enum value same as Code /// public CloseStatusCode StatusCode { get { if (Enum.IsDefined(typeof(CloseStatusCode), Code)) return (CloseStatusCode)Code; return CloseStatusCode.Unknown; } } #endregion } }