From e594696a383dba18c67fe4daaaa7e05b5533510f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Mar 2014 17:02:41 +0900 Subject: [PATCH] Modified CompressionMethod enum values to PascalCase values --- Example/Program.cs | 2 +- Example1/AudioStreamer.cs | 2 +- README.md | 2 +- websocket-sharp/CompressionMethod.cs | 22 ++++++++++++---------- websocket-sharp/Ext.cs | 16 ++++++++-------- websocket-sharp/WebSocket.cs | 28 ++++++++++++++-------------- 6 files changed, 37 insertions(+), 35 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index 91477fbc..c6be15a8 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -113,7 +113,7 @@ namespace Example { #if DEBUG ws.Log.Level = LogLevel.Trace; #endif - //ws.Compression = CompressionMethod.DEFLATE; + //ws.Compression = CompressionMethod.Deflate; //ws.Origin = "http://echo.websocket.org"; //ws.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => //{ diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index 5b7aa951..d9994cfd 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -123,7 +123,7 @@ namespace Example1 ); }; - //_ws.Compression = CompressionMethod.DEFLATE; + //_ws.Compression = CompressionMethod.Deflate; _notifyMsgState = new ThreadState(); _notifyMsg = (state) => diff --git a/README.md b/README.md index 4251d0b2..53bdf84d 100644 --- a/README.md +++ b/README.md @@ -390,7 +390,7 @@ websocket-sharp supports the **[Per-message Compression][compression]** extensio If you would like to enable this extension as a WebSocket client, you should set like the following. ```cs -ws.Compression = CompressionMethod.DEFLATE; +ws.Compression = CompressionMethod.Deflate; ``` And then your client sends the following header with the connection request to the server. diff --git a/websocket-sharp/CompressionMethod.cs b/websocket-sharp/CompressionMethod.cs index dcd7bc6f..b49315a8 100644 --- a/websocket-sharp/CompressionMethod.cs +++ b/websocket-sharp/CompressionMethod.cs @@ -4,8 +4,8 @@ * * The MIT License * - * Copyright (c) 2013 sta.blockhead - * + * Copyright (c) 2013-2014 sta.blockhead + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights @@ -15,7 +15,7 @@ * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -28,24 +28,26 @@ using System; -namespace WebSocketSharp { - +namespace WebSocketSharp +{ /// - /// Contains the values of the compression methods used to compress the payload data of the WebSocket Data frame. + /// Contains the values of the compression methods used to compress the message on the WebSocket + /// connection. /// /// - /// The CompressionMethod enumeration contains the values of the compression methods defined in - /// Compression Extensions for WebSocket. + /// The compression methods are defined in + /// Compression + /// Extensions for WebSocket. /// public enum CompressionMethod : byte { /// /// Indicates non compression. /// - NONE, + None, /// /// Indicates using DEFLATE. /// - DEFLATE + Deflate } } diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7600b83d..6a95cb46 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -319,21 +319,21 @@ namespace WebSocketSharp internal static byte [] Compress (this byte [] value, CompressionMethod method) { - return method == CompressionMethod.DEFLATE + return method == CompressionMethod.Deflate ? value.compress () : value; } internal static Stream Compress (this Stream stream, CompressionMethod method) { - return method == CompressionMethod.DEFLATE + return method == CompressionMethod.Deflate ? stream.compress () : stream; } internal static byte [] CompressToArray (this Stream stream, CompressionMethod method) { - return method == CompressionMethod.DEFLATE + return method == CompressionMethod.Deflate ? stream.compressToArray () : stream.ToByteArray (); } @@ -395,21 +395,21 @@ namespace WebSocketSharp internal static byte [] Decompress (this byte [] value, CompressionMethod method) { - return method == CompressionMethod.DEFLATE + return method == CompressionMethod.Deflate ? value.decompress () : value; } internal static Stream Decompress (this Stream stream, CompressionMethod method) { - return method == CompressionMethod.DEFLATE + return method == CompressionMethod.Deflate ? stream.decompress () : stream; } internal static byte [] DecompressToArray (this Stream stream, CompressionMethod method) { - return method == CompressionMethod.DEFLATE + return method == CompressionMethod.Deflate ? stream.decompressToArray () : stream.ToByteArray (); } @@ -787,12 +787,12 @@ namespace WebSocketSharp if (method.ToExtensionString () == value) return method; - return CompressionMethod.NONE; + return CompressionMethod.None; } internal static string ToExtensionString (this CompressionMethod method) { - return method != CompressionMethod.NONE + return method != CompressionMethod.None ? String.Format ("permessage-{0}", method.ToString ().ToLower ()) : String.Empty; } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 75acd34b..ad98329a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -218,7 +218,7 @@ namespace WebSocketSharp /// /// /// One of the enum values, indicates the compression method - /// used to compress the message. The default value is . + /// used to compress the message. The default value is . /// public CompressionMethod Compression { get { @@ -543,7 +543,7 @@ namespace WebSocketSharp return false; byte [] data; - if (_compression != CompressionMethod.NONE) { + if (_compression != CompressionMethod.None) { data = concatenated.DecompressToArray (_compression); } else { @@ -558,7 +558,7 @@ namespace WebSocketSharp private bool acceptFrame (WsFrame frame) { - return frame.IsCompressed && _compression == CompressionMethod.NONE + return frame.IsCompressed && _compression == CompressionMethod.None ? acceptUnsupportedFrame ( frame, CloseStatusCode.IncorrectData, @@ -632,7 +632,7 @@ namespace WebSocketSharp if (!compress && unprefixed.IsCompressionExtension ()) { var method = unprefixed.ToCompressionMethod (); - if (method != CompressionMethod.NONE) { + if (method != CompressionMethod.None) { _compression = method; compress = true; @@ -888,7 +888,7 @@ namespace WebSocketSharp { var extensions = new StringBuilder (32); - if (_compression != CompressionMethod.NONE) + if (_compression != CompressionMethod.None) extensions.Append (_compression.ToExtensionString ()); return extensions.Length > 0 @@ -997,7 +997,7 @@ namespace WebSocketSharp private void init () { - _compression = CompressionMethod.NONE; + _compression = CompressionMethod.None; _cookies = new CookieCollection (); _forConn = new object (); _forSend = new object (); @@ -1073,7 +1073,7 @@ namespace WebSocketSharp var sent = false; try { var compressed = false; - if (_compression != CompressionMethod.NONE) { + if (_compression != CompressionMethod.None) { data = data.Compress (_compression); compressed = true; } @@ -1097,7 +1097,7 @@ namespace WebSocketSharp var src = stream; var compressed = false; try { - if (_compression != CompressionMethod.NONE) { + if (_compression != CompressionMethod.None) { stream = stream.Compress (_compression); compressed = true; } @@ -1293,10 +1293,10 @@ namespace WebSocketSharp // As client private bool validateSecWebSocketExtensionsHeader (string value) { - var compress = _compression != CompressionMethod.NONE ? true : false; + var compress = _compression != CompressionMethod.None; if (value == null || value.Length == 0) { if (compress) - _compression = CompressionMethod.NONE; + _compression = CompressionMethod.None; return true; } @@ -1447,7 +1447,7 @@ namespace WebSocketSharp opcode, Mask.Unmask, data.Compress (_compression), - _compression != CompressionMethod.NONE) + _compression != CompressionMethod.None) .ToByteArray (); cache.Add (_compression, cached); @@ -1477,7 +1477,7 @@ namespace WebSocketSharp cached.Position = 0; if (_readyState == WebSocketState.OPEN) - sendFragmented (opcode, cached, Mask.Unmask, _compression != CompressionMethod.NONE); + sendFragmented (opcode, cached, Mask.Unmask, _compression != CompressionMethod.None); } catch (Exception ex) { _logger.Fatal (ex.ToString ()); @@ -1850,7 +1850,7 @@ namespace WebSocketSharp if (len <= FragmentLength) send ( Opcode.BINARY, - len > 0 && _client && _compression == CompressionMethod.NONE ? data.Copy (len) : data); + len > 0 && _client && _compression == CompressionMethod.None ? data.Copy (len) : data); else send (Opcode.BINARY, new MemoryStream (data)); } @@ -1926,7 +1926,7 @@ namespace WebSocketSharp if (len <= FragmentLength) sendAsync ( Opcode.BINARY, - len > 0 && _client && _compression == CompressionMethod.NONE ? data.Copy (len) : data, + len > 0 && _client && _compression == CompressionMethod.None ? data.Copy (len) : data, completed); else sendAsync (Opcode.BINARY, new MemoryStream (data), completed);