From eb36dd9e827752bce8b07dcfd8f05d0b40a30b50 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Mar 2014 17:32:06 +0900 Subject: [PATCH] Modified CloseStatusCode enum values to PascalCase values --- websocket-sharp/CloseEventArgs.cs | 2 +- websocket-sharp/CloseStatusCode.cs | 76 +++++++++---------- websocket-sharp/Ext.cs | 34 ++++----- websocket-sharp/MessageEventArgs.cs | 2 +- websocket-sharp/Server/HttpServer.cs | 2 +- websocket-sharp/Server/WebSocketServer.cs | 2 +- websocket-sharp/Server/WebSocketService.cs | 2 +- .../Server/WebSocketServiceManager.cs | 2 +- .../Server/WebSocketSessionManager.cs | 2 +- websocket-sharp/WebSocket.cs | 16 ++-- websocket-sharp/WebSocketException.cs | 6 +- websocket-sharp/WsFrame.cs | 6 +- 12 files changed, 73 insertions(+), 79 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 0933f1cf..93a6e9b2 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -114,7 +114,7 @@ namespace WebSocketSharp { return data.Length > 1 ? data.SubArray (0, 2).ToUInt16 (ByteOrder.Big) - : (ushort) CloseStatusCode.NO_STATUS_CODE; + : (ushort) CloseStatusCode.NoStatusCode; } private static string getReasonFrom (byte [] data) diff --git a/websocket-sharp/CloseStatusCode.cs b/websocket-sharp/CloseStatusCode.cs index bc2f6508..30f9c7c3 100644 --- a/websocket-sharp/CloseStatusCode.cs +++ b/websocket-sharp/CloseStatusCode.cs @@ -31,20 +31,18 @@ using System; namespace WebSocketSharp { /// - /// Contains the values of the status codes for the WebSocket connection - /// closure. + /// Contains the values of the status codes for the WebSocket connection closure. /// /// /// - /// The CloseStatusCode enumeration contains the values of the status codes - /// for the WebSocket connection closure defined in + /// The status codes for the WebSocket connection closure are defined in /// RFC 6455 /// for the WebSocket protocol. /// /// - /// "Reserved value" must not be set as a status code in a close control frame - /// by an endpoint. It's designated for use in applications expecting a status - /// code to indicate that the connection was closed due to a system grounds. + /// "Reserved value" must not be set as a status code in a close control frame by + /// an endpoint. It's designated for use in applications expecting a status code + /// to indicate that the connection was closed due to a system grounds. /// /// public enum CloseStatusCode : ushort @@ -53,78 +51,74 @@ namespace WebSocketSharp /// Equivalent to close status 1000. /// Indicates a normal closure. /// - NORMAL = 1000, + Normal = 1000, /// /// Equivalent to close status 1001. - /// Indicates that an endpoint is "going away". + /// Indicates that an endpoint is going away. /// - AWAY = 1001, + Away = 1001, /// /// Equivalent to close status 1002. - /// Indicates that an endpoint is terminating the connection due to a protocol - /// error. + /// Indicates that an endpoint is terminating the connection due to a protocol error. /// - PROTOCOL_ERROR = 1002, + ProtocolError = 1002, /// /// Equivalent to close status 1003. - /// Indicates that an endpoint is terminating the connection because it has - /// received a type of data it cannot accept. + /// Indicates that an endpoint is terminating the connection because it has received an + /// unacceptable type message. /// - INCORRECT_DATA = 1003, + IncorrectData = 1003, /// /// Equivalent to close status 1004. /// Still undefined. Reserved value. /// - UNDEFINED = 1004, + Undefined = 1004, /// /// Equivalent to close status 1005. /// Indicates that no status code was actually present. Reserved value. /// - NO_STATUS_CODE = 1005, + NoStatusCode = 1005, /// /// Equivalent to close status 1006. /// Indicates that the connection was closed abnormally. Reserved value. /// - ABNORMAL = 1006, + Abnormal = 1006, /// /// Equivalent to close status 1007. - /// Indicates that an endpoint is terminating the connection because it has - /// received the data within a message that wasn't consistent with the type of - /// the message. + /// Indicates that an endpoint is terminating the connection because it has received a message + /// that contains a data that isn't consistent with the type of the message. /// - INCONSISTENT_DATA = 1007, + InconsistentData = 1007, /// /// Equivalent to close status 1008. - /// Indicates that an endpoint is terminating the connection because it has - /// received a message that violates its policy. + /// Indicates that an endpoint is terminating the connection because it has received a message + /// that violates its policy. /// - POLICY_VIOLATION = 1008, + PolicyViolation = 1008, /// /// Equivalent to close status 1009. - /// Indicates that an endpoint is terminating the connection because it has - /// received a message that is too big to process. + /// Indicates that an endpoint is terminating the connection because it has received a message + /// that is too big to process. /// - TOO_BIG = 1009, + TooBig = 1009, /// /// Equivalent to close status 1010. - /// Indicates that an endpoint (client) is terminating the connection because - /// it has expected the server to negotiate one or more extension, but the - /// server didn't return them in the response message of the WebSocket - /// handshake. + /// Indicates that the client is terminating the connection because it has expected the server + /// to negotiate one or more extension, but the server didn't return them in the handshake + /// response. /// - IGNORE_EXTENSION = 1010, + IgnoreExtension = 1010, /// /// Equivalent to close status 1011. - /// Indicates that the server is terminating the connection because it has - /// encountered an unexpected condition that prevented it from fulfilling the - /// request. + /// Indicates that the server is terminating the connection because it has encountered an + /// unexpected condition that prevented it from fulfilling the request. /// - SERVER_ERROR = 1011, + ServerError = 1011, /// /// Equivalent to close status 1015. - /// Indicates that the connection was closed due to a failure to perform a TLS - /// handshake. Reserved value. + /// Indicates that the connection was closed due to a failure to perform a TLS handshake. + /// Reserved value. /// - TLS_HANDSHAKE_FAILURE = 1015 + TlsHandshakeFailure = 1015 } } diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 35667e92..7600b83d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -472,23 +472,23 @@ namespace WebSocketSharp internal static string GetMessage (this CloseStatusCode code) { - return code == CloseStatusCode.PROTOCOL_ERROR + return code == CloseStatusCode.ProtocolError ? "A WebSocket protocol error has occurred." - : code == CloseStatusCode.INCORRECT_DATA + : code == CloseStatusCode.IncorrectData ? "An incorrect data has been received." - : code == CloseStatusCode.ABNORMAL + : code == CloseStatusCode.Abnormal ? "An exception has occurred." - : code == CloseStatusCode.INCONSISTENT_DATA + : code == CloseStatusCode.InconsistentData ? "An inconsistent data has been received." - : code == CloseStatusCode.POLICY_VIOLATION + : code == CloseStatusCode.PolicyViolation ? "A policy violation has occurred." - : code == CloseStatusCode.TOO_BIG + : code == CloseStatusCode.TooBig ? "A too big data has been received." - : code == CloseStatusCode.IGNORE_EXTENSION + : code == CloseStatusCode.IgnoreExtension ? "WebSocket client did not receive expected extension(s)." - : code == CloseStatusCode.SERVER_ERROR + : code == CloseStatusCode.ServerError ? "WebSocket server got an internal error." - : code == CloseStatusCode.TLS_HANDSHAKE_FAILURE + : code == CloseStatusCode.TlsHandshakeFailure ? "An error has occurred while handshaking." : String.Empty; } @@ -527,18 +527,18 @@ namespace WebSocketSharp internal static bool IsReserved (this ushort code) { - return code == (ushort) CloseStatusCode.UNDEFINED || - code == (ushort) CloseStatusCode.NO_STATUS_CODE || - code == (ushort) CloseStatusCode.ABNORMAL || - code == (ushort) CloseStatusCode.TLS_HANDSHAKE_FAILURE; + return code == (ushort) CloseStatusCode.Undefined || + code == (ushort) CloseStatusCode.NoStatusCode || + code == (ushort) CloseStatusCode.Abnormal || + code == (ushort) CloseStatusCode.TlsHandshakeFailure; } internal static bool IsReserved (this CloseStatusCode code) { - return code == CloseStatusCode.UNDEFINED || - code == CloseStatusCode.NO_STATUS_CODE || - code == CloseStatusCode.ABNORMAL || - code == CloseStatusCode.TLS_HANDSHAKE_FAILURE; + return code == CloseStatusCode.Undefined || + code == CloseStatusCode.NoStatusCode || + code == CloseStatusCode.Abnormal || + code == CloseStatusCode.TlsHandshakeFailure; } internal static bool IsText (this string value) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 64d1583a..404378d5 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -55,7 +55,7 @@ namespace WebSocketSharp internal MessageEventArgs (Opcode opcode, byte[] data) { if ((ulong) data.LongLength > PayloadData.MaxLength) - throw new WebSocketException (CloseStatusCode.TOO_BIG); + throw new WebSocketException (CloseStatusCode.TooBig); _opcode = opcode; _rawData = data; diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 723e83c8..7af6d80c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -410,7 +410,7 @@ namespace WebSocketSharp.Server } _services.Stop ( - ((ushort) CloseStatusCode.SERVER_ERROR).ToByteArrayInternally (ByteOrder.Big), true); + ((ushort) CloseStatusCode.ServerError).ToByteArrayInternally (ByteOrder.Big), true); _listener.Abort (); _state = ServerState.Stop; diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index bf49c8ce..3c7e7819 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -466,7 +466,7 @@ namespace WebSocketSharp.Server _listener.Stop (); _services.Stop ( - ((ushort) CloseStatusCode.SERVER_ERROR).ToByteArrayInternally (ByteOrder.Big), true); + ((ushort) CloseStatusCode.ServerError).ToByteArrayInternally (ByteOrder.Big), true); _state = ServerState.Stop; } diff --git a/websocket-sharp/Server/WebSocketService.cs b/websocket-sharp/Server/WebSocketService.cs index 6a5f02c3..50d7c738 100644 --- a/websocket-sharp/Server/WebSocketService.cs +++ b/websocket-sharp/Server/WebSocketService.cs @@ -215,7 +215,7 @@ namespace WebSocketSharp.Server { ID = _sessions.Add (this); if (ID == null) { - _websocket.Close (CloseStatusCode.AWAY); + _websocket.Close (CloseStatusCode.Away); return; } diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 7e60b5c5..65c50c36 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -295,7 +295,7 @@ namespace WebSocketSharp.Server if (host.Sessions.State == ServerState.Start) host.Sessions.Stop ( - ((ushort) CloseStatusCode.AWAY).ToByteArrayInternally (ByteOrder.Big), true); + ((ushort) CloseStatusCode.Away).ToByteArrayInternally (ByteOrder.Big), true); return true; } diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 03770f79..20a610af 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -812,7 +812,7 @@ namespace WebSocketSharp.Server if (_sessions.TryGetValue (id, out session)) { var state = session.State; if (state == WebSocketState.OPEN) - session.Context.WebSocket.Close (CloseStatusCode.ABNORMAL); + session.Context.WebSocket.Close (CloseStatusCode.Abnormal); else if (state == WebSocketState.CLOSING) continue; else diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index faf86f90..ead0ea07 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -504,7 +504,7 @@ namespace WebSocketSharp private void acceptException (Exception exception, string reason) { - var code = CloseStatusCode.ABNORMAL; + var code = CloseStatusCode.Abnormal; var msg = reason; if (exception is WebSocketException) { var wsex = (WebSocketException) exception; @@ -512,7 +512,7 @@ namespace WebSocketSharp reason = wsex.Message; } - if (code == CloseStatusCode.ABNORMAL || code == CloseStatusCode.TLS_HANDSHAKE_FAILURE) { + if (code == CloseStatusCode.Abnormal || code == CloseStatusCode.TlsHandshakeFailure) { _logger.Fatal (exception.ToString ()); reason = msg; } @@ -561,7 +561,7 @@ namespace WebSocketSharp return frame.IsCompressed && _compression == CompressionMethod.NONE ? acceptUnsupportedFrame ( frame, - CloseStatusCode.INCORRECT_DATA, + CloseStatusCode.IncorrectData, "A compressed data has been received without available decompression method.") : frame.IsFragmented ? acceptFragmentedFrame (frame) @@ -573,7 +573,7 @@ namespace WebSocketSharp ? acceptPongFrame (frame) : frame.IsClose ? acceptCloseFrame (frame) - : acceptUnsupportedFrame (frame, CloseStatusCode.POLICY_VIOLATION, null); + : acceptUnsupportedFrame (frame, CloseStatusCode.PolicyViolation, null); } // As server @@ -851,7 +851,7 @@ namespace WebSocketSharp // ? return acceptUnsupportedFrame ( frame, - CloseStatusCode.INCORRECT_DATA, + CloseStatusCode.IncorrectData, "An incorrect data has been received while receiving fragmented data."); } @@ -978,7 +978,7 @@ namespace WebSocketSharp msg = "An error has occurred while connecting."; error (msg); - close (CloseStatusCode.ABNORMAL, msg, false); + close (CloseStatusCode.Abnormal, msg, false); return false; } @@ -1780,11 +1780,11 @@ namespace WebSocketSharp /// Closes the WebSocket connection, and releases all associated resources. /// /// - /// This method closes the WebSocket connection with . + /// This method closes the WebSocket connection with . /// public void Dispose () { - Close (CloseStatusCode.AWAY, null); + Close (CloseStatusCode.Away, null); } /// diff --git a/websocket-sharp/WebSocketException.cs b/websocket-sharp/WebSocketException.cs index d237792a..aebe5e59 100644 --- a/websocket-sharp/WebSocketException.cs +++ b/websocket-sharp/WebSocketException.cs @@ -39,7 +39,7 @@ namespace WebSocketSharp #region Internal Constructors internal WebSocketException () - : this (CloseStatusCode.ABNORMAL, null, null) + : this (CloseStatusCode.Abnormal, null, null) { } @@ -49,12 +49,12 @@ namespace WebSocketSharp } internal WebSocketException (string reason) - : this (CloseStatusCode.ABNORMAL, reason, null) + : this (CloseStatusCode.Abnormal, reason, null) { } internal WebSocketException (string reason, Exception innerException) - : this (CloseStatusCode.ABNORMAL, reason, innerException) + : this (CloseStatusCode.Abnormal, reason, innerException) { } diff --git a/websocket-sharp/WsFrame.cs b/websocket-sharp/WsFrame.cs index 94752d9c..d4eb4555 100644 --- a/websocket-sharp/WsFrame.cs +++ b/websocket-sharp/WsFrame.cs @@ -397,12 +397,12 @@ namespace WebSocketSharp : null; if (incorrect != null) - throw new WebSocketException (CloseStatusCode.INCORRECT_DATA, incorrect); + throw new WebSocketException (CloseStatusCode.IncorrectData, incorrect); // Check if consistent frame. if (isControl (opcode) && payloadLen > 125) throw new WebSocketException ( - CloseStatusCode.INCONSISTENT_DATA, + CloseStatusCode.InconsistentData, "The payload data length of a control frame is greater than 125 bytes."); var frame = new WsFrame { @@ -460,7 +460,7 @@ namespace WebSocketSharp // Check if allowable payload data length. if (payloadLen > 126 && dataLen > PayloadData.MaxLength) throw new WebSocketException ( - CloseStatusCode.TOO_BIG, "The 'Payload Data' length is greater than the allowable length."); + CloseStatusCode.TooBig, "The 'Payload Data' length is greater than the allowable length."); data = payloadLen > 126 ? stream.ReadBytes ((long) dataLen, 1024)