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

View File

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

View File

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

View File

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

View File

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

View File

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