Renamed some of the CloseStatusCode enum values

This commit is contained in:
sta 2015-04-28 17:32:40 +09:00
parent 06b4084a06
commit 33f578f94b
6 changed files with 39 additions and 39 deletions

View File

@ -63,7 +63,7 @@ namespace WebSocketSharp
_payloadData = new PayloadData ();
_rawData = _payloadData.ApplicationData;
_code = (ushort) CloseStatusCode.NoStatusCode;
_code = (ushort) CloseStatusCode.NoStatus;
_reason = String.Empty;
}
@ -87,7 +87,7 @@ namespace WebSocketSharp
var len = _rawData.Length;
_code = len > 1
? _rawData.SubArray (0, 2).ToUInt16 (ByteOrder.Big)
: (ushort) CloseStatusCode.NoStatusCode;
: (ushort) CloseStatusCode.NoStatus;
_reason = len > 2
? Encoding.UTF8.GetString (_rawData.SubArray (2, len - 2))

View File

@ -65,9 +65,9 @@ namespace WebSocketSharp
/// <summary>
/// Equivalent to close status 1003.
/// Indicates that an endpoint is terminating the connection because it has received
/// an unacceptable type message.
/// a type of data that it cannot accept.
/// </summary>
IncorrectData = 1003,
UnsupportedData = 1003,
/// <summary>
/// Equivalent to close status 1004.
/// Still undefined. A Reserved value.
@ -77,7 +77,7 @@ namespace WebSocketSharp
/// Equivalent to close status 1005.
/// Indicates that no status code was actually present. A Reserved value.
/// </summary>
NoStatusCode = 1005,
NoStatus = 1005,
/// <summary>
/// Equivalent to close status 1006.
/// Indicates that the connection was closed abnormally. A Reserved value.
@ -88,7 +88,7 @@ namespace WebSocketSharp
/// Indicates that an endpoint is terminating the connection because it has received
/// a message that contains data that isn't consistent with the type of the message.
/// </summary>
InconsistentData = 1007,
InvalidData = 1007,
/// <summary>
/// Equivalent to close status 1008.
/// Indicates that an endpoint is terminating the connection because it has received
@ -107,7 +107,7 @@ namespace WebSocketSharp
/// the server to negotiate one or more extension, but the server didn't return them
/// in the handshake response.
/// </summary>
IgnoreExtension = 1010,
MandatoryExtension = 1010,
/// <summary>
/// Equivalent to close status 1011.
/// Indicates that the server is terminating the connection because it has encountered

View File

@ -255,8 +255,8 @@ namespace WebSocketSharp
{
return !code.IsCloseStatusCode ()
? "An invalid close status code."
: code.IsNoStatusCode () && !reason.IsNullOrEmpty ()
? "NoStatusCode cannot have a reason."
: code.IsNoStatus () && !reason.IsNullOrEmpty ()
? "NoStatus cannot have a reason."
: !reason.IsNullOrEmpty () && Encoding.UTF8.GetBytes (reason).Length > 123
? "A reason has greater than the allowable max size."
: null;
@ -264,8 +264,8 @@ namespace WebSocketSharp
internal static string CheckIfValidCloseParameters (this CloseStatusCode code, string reason)
{
return code.IsNoStatusCode () && !reason.IsNullOrEmpty ()
? "NoStatusCode cannot have a reason."
return code.IsNoStatus () && !reason.IsNullOrEmpty ()
? "NoStatus cannot have a reason."
: !reason.IsNullOrEmpty () && Encoding.UTF8.GetBytes (reason).Length > 123
? "A reason has greater than the allowable max size."
: null;
@ -496,22 +496,22 @@ namespace WebSocketSharp
{
return code == CloseStatusCode.ProtocolError
? "A WebSocket protocol error has occurred."
: code == CloseStatusCode.IncorrectData
? "An incorrect data has been received."
: code == CloseStatusCode.UnsupportedData
? "Unsupported data has been received."
: code == CloseStatusCode.Abnormal
? "An exception has occurred."
: code == CloseStatusCode.InconsistentData
? "An inconsistent data has been received."
: code == CloseStatusCode.InvalidData
? "Invalid data has been received."
: code == CloseStatusCode.PolicyViolation
? "A policy violation has occurred."
: code == CloseStatusCode.TooBig
? "A too big data has been received."
: code == CloseStatusCode.IgnoreExtension
? "A too big message has been received."
: code == CloseStatusCode.MandatoryExtension
? "WebSocket client didn't receive expected extension(s)."
: code == CloseStatusCode.ServerError
? "WebSocket server got an internal error."
: code == CloseStatusCode.TlsHandshakeFailure
? "An error has occurred while handshaking."
? "An error has occurred during a TLS handshake."
: String.Empty;
}
@ -604,14 +604,14 @@ namespace WebSocketSharp
return value.StartsWith (method.ToExtensionString ());
}
internal static bool IsNoStatusCode (this ushort code)
internal static bool IsNoStatus (this ushort code)
{
return code == (ushort) CloseStatusCode.NoStatusCode;
return code == (ushort) CloseStatusCode.NoStatus;
}
internal static bool IsNoStatusCode (this CloseStatusCode code)
internal static bool IsNoStatus (this CloseStatusCode code)
{
return code == CloseStatusCode.NoStatusCode;
return code == CloseStatusCode.NoStatus;
}
internal static bool IsPortNumber (this int value)
@ -622,7 +622,7 @@ namespace WebSocketSharp
internal static bool IsReserved (this ushort code)
{
return code == (ushort) CloseStatusCode.Undefined ||
code == (ushort) CloseStatusCode.NoStatusCode ||
code == (ushort) CloseStatusCode.NoStatus ||
code == (ushort) CloseStatusCode.Abnormal ||
code == (ushort) CloseStatusCode.TlsHandshakeFailure;
}
@ -630,7 +630,7 @@ namespace WebSocketSharp
internal static bool IsReserved (this CloseStatusCode code)
{
return code == CloseStatusCode.Undefined ||
code == CloseStatusCode.NoStatusCode ||
code == CloseStatusCode.NoStatus ||
code == CloseStatusCode.Abnormal ||
code == CloseStatusCode.TlsHandshakeFailure;
}

View File

@ -766,7 +766,7 @@ namespace WebSocketSharp.Server
_state = ServerState.ShuttingDown;
}
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
_services.Stop (new CloseEventArgs (), true, true);
}
else {
@ -802,7 +802,7 @@ namespace WebSocketSharp.Server
_state = ServerState.ShuttingDown;
}
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
_services.Stop (new CloseEventArgs (), true, true);
}
else {

View File

@ -852,7 +852,7 @@ namespace WebSocketSharp.Server
}
stopReceiving (5000);
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
_services.Stop (new CloseEventArgs (), true, true);
}
else {
@ -887,7 +887,7 @@ namespace WebSocketSharp.Server
}
stopReceiving (5000);
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
_services.Stop (new CloseEventArgs (), true, true);
}
else {

View File

@ -773,8 +773,8 @@ namespace WebSocketSharp
// ?
return processUnsupportedFrame (
frame,
CloseStatusCode.IncorrectData,
"Incorrect data has been received while receiving the fragmented data.");
CloseStatusCode.UnsupportedData,
"Unsupported data has been received while receiving the fragmented data.");
}
return true;
@ -1075,7 +1075,7 @@ namespace WebSocketSharp
? processPongFrame (frame)
: frame.IsClose
? processCloseFrame (frame)
: processUnsupportedFrame (frame, CloseStatusCode.IncorrectData, null);
: processUnsupportedFrame (frame, CloseStatusCode.UnsupportedData, null);
}
// As server
@ -1746,7 +1746,7 @@ namespace WebSocketSharp
return;
}
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
close (new CloseEventArgs (), true, true);
return;
}
@ -1773,7 +1773,7 @@ namespace WebSocketSharp
return;
}
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
close (new CloseEventArgs (), true, true);
return;
}
@ -1807,7 +1807,7 @@ namespace WebSocketSharp
return;
}
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
close (new CloseEventArgs (), true, true);
return;
}
@ -1841,7 +1841,7 @@ namespace WebSocketSharp
return;
}
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
close (new CloseEventArgs (), true, true);
return;
}
@ -1895,7 +1895,7 @@ namespace WebSocketSharp
return;
}
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
closeAsync (new CloseEventArgs (), true, true);
return;
}
@ -1925,7 +1925,7 @@ namespace WebSocketSharp
return;
}
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
closeAsync (new CloseEventArgs (), true, true);
return;
}
@ -1964,7 +1964,7 @@ namespace WebSocketSharp
return;
}
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
closeAsync (new CloseEventArgs (), true, true);
return;
}
@ -2004,7 +2004,7 @@ namespace WebSocketSharp
return;
}
if (code.IsNoStatusCode ()) {
if (code.IsNoStatus ()) {
closeAsync (new CloseEventArgs (), true, true);
return;
}