EonaCat.Network/EonaCat.Network/System/Sockets/Web/EventArgs/CloseEventArgs.cs

60 lines
1.4 KiB
C#

// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
using System;
namespace EonaCat.Network
{
public class CloseEventArgs : EventArgs
{
internal CloseEventArgs()
{
Payload = Payload.Empty;
}
internal CloseEventArgs(ushort code)
: this(code, null)
{
}
internal CloseEventArgs(CloseStatusCode code)
: this((ushort)code, null)
{
}
internal CloseEventArgs(Payload payload)
{
Payload = payload;
}
internal CloseEventArgs(ushort code, string reason)
{
Payload = new Payload(code, reason);
}
internal CloseEventArgs(CloseStatusCode code, string reason)
: this((ushort)code, reason)
{
}
/// <summary>
/// Code
/// </summary>
public ushort Code => Payload.Code;
/// <summary>
/// Reason
/// </summary>
public string Reason => Payload.Reason ?? string.Empty;
/// <summary>
/// Determnines if both the client and server requests where handled
/// </summary>
public bool WasClean { get; internal set; }
/// <summary>
/// Payload
/// </summary>
internal Payload Payload { get; }
}
}