Modified CompressionMethod enum values to PascalCase values

master
sta 12 years ago
parent 639b056f1a
commit e594696a38

@ -113,7 +113,7 @@ namespace Example {
#if DEBUG #if DEBUG
ws.Log.Level = LogLevel.Trace; ws.Log.Level = LogLevel.Trace;
#endif #endif
//ws.Compression = CompressionMethod.DEFLATE; //ws.Compression = CompressionMethod.Deflate;
//ws.Origin = "http://echo.websocket.org"; //ws.Origin = "http://echo.websocket.org";
//ws.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => //ws.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
//{ //{

@ -123,7 +123,7 @@ namespace Example1
); );
}; };
//_ws.Compression = CompressionMethod.DEFLATE; //_ws.Compression = CompressionMethod.Deflate;
_notifyMsgState = new ThreadState(); _notifyMsgState = new ThreadState();
_notifyMsg = (state) => _notifyMsg = (state) =>

@ -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. If you would like to enable this extension as a WebSocket client, you should set like the following.
```cs ```cs
ws.Compression = CompressionMethod.DEFLATE; ws.Compression = CompressionMethod.Deflate;
``` ```
And then your client sends the following header with the connection request to the server. And then your client sends the following header with the connection request to the server.

@ -4,7 +4,7 @@
* *
* The MIT License * 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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -28,24 +28,26 @@
using System; using System;
namespace WebSocketSharp { namespace WebSocketSharp
{
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// The <b>CompressionMethod</b> enumeration contains the values of the compression methods defined in /// The compression methods are defined in
/// <see href="http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-09">Compression Extensions for WebSocket</see>. /// <see href="http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-09">Compression
/// Extensions for WebSocket</see>.
/// </remarks> /// </remarks>
public enum CompressionMethod : byte public enum CompressionMethod : byte
{ {
/// <summary> /// <summary>
/// Indicates non compression. /// Indicates non compression.
/// </summary> /// </summary>
NONE, None,
/// <summary> /// <summary>
/// Indicates using DEFLATE. /// Indicates using DEFLATE.
/// </summary> /// </summary>
DEFLATE Deflate
} }
} }

@ -319,21 +319,21 @@ namespace WebSocketSharp
internal static byte [] Compress (this byte [] value, CompressionMethod method) internal static byte [] Compress (this byte [] value, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.Deflate
? value.compress () ? value.compress ()
: value; : value;
} }
internal static Stream Compress (this Stream stream, CompressionMethod method) internal static Stream Compress (this Stream stream, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.Deflate
? stream.compress () ? stream.compress ()
: stream; : stream;
} }
internal static byte [] CompressToArray (this Stream stream, CompressionMethod method) internal static byte [] CompressToArray (this Stream stream, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.Deflate
? stream.compressToArray () ? stream.compressToArray ()
: stream.ToByteArray (); : stream.ToByteArray ();
} }
@ -395,21 +395,21 @@ namespace WebSocketSharp
internal static byte [] Decompress (this byte [] value, CompressionMethod method) internal static byte [] Decompress (this byte [] value, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.Deflate
? value.decompress () ? value.decompress ()
: value; : value;
} }
internal static Stream Decompress (this Stream stream, CompressionMethod method) internal static Stream Decompress (this Stream stream, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.Deflate
? stream.decompress () ? stream.decompress ()
: stream; : stream;
} }
internal static byte [] DecompressToArray (this Stream stream, CompressionMethod method) internal static byte [] DecompressToArray (this Stream stream, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.Deflate
? stream.decompressToArray () ? stream.decompressToArray ()
: stream.ToByteArray (); : stream.ToByteArray ();
} }
@ -787,12 +787,12 @@ namespace WebSocketSharp
if (method.ToExtensionString () == value) if (method.ToExtensionString () == value)
return method; return method;
return CompressionMethod.NONE; return CompressionMethod.None;
} }
internal static string ToExtensionString (this CompressionMethod method) internal static string ToExtensionString (this CompressionMethod method)
{ {
return method != CompressionMethod.NONE return method != CompressionMethod.None
? String.Format ("permessage-{0}", method.ToString ().ToLower ()) ? String.Format ("permessage-{0}", method.ToString ().ToLower ())
: String.Empty; : String.Empty;
} }

@ -218,7 +218,7 @@ namespace WebSocketSharp
/// </summary> /// </summary>
/// <value> /// <value>
/// One of the <see cref="CompressionMethod"/> enum values, indicates the compression method /// One of the <see cref="CompressionMethod"/> enum values, indicates the compression method
/// used to compress the message. The default value is <see cref="CompressionMethod.NONE"/>. /// used to compress the message. The default value is <see cref="CompressionMethod.None"/>.
/// </value> /// </value>
public CompressionMethod Compression { public CompressionMethod Compression {
get { get {
@ -543,7 +543,7 @@ namespace WebSocketSharp
return false; return false;
byte [] data; byte [] data;
if (_compression != CompressionMethod.NONE) { if (_compression != CompressionMethod.None) {
data = concatenated.DecompressToArray (_compression); data = concatenated.DecompressToArray (_compression);
} }
else { else {
@ -558,7 +558,7 @@ namespace WebSocketSharp
private bool acceptFrame (WsFrame frame) private bool acceptFrame (WsFrame frame)
{ {
return frame.IsCompressed && _compression == CompressionMethod.NONE return frame.IsCompressed && _compression == CompressionMethod.None
? acceptUnsupportedFrame ( ? acceptUnsupportedFrame (
frame, frame,
CloseStatusCode.IncorrectData, CloseStatusCode.IncorrectData,
@ -632,7 +632,7 @@ namespace WebSocketSharp
if (!compress && unprefixed.IsCompressionExtension ()) { if (!compress && unprefixed.IsCompressionExtension ()) {
var method = unprefixed.ToCompressionMethod (); var method = unprefixed.ToCompressionMethod ();
if (method != CompressionMethod.NONE) { if (method != CompressionMethod.None) {
_compression = method; _compression = method;
compress = true; compress = true;
@ -888,7 +888,7 @@ namespace WebSocketSharp
{ {
var extensions = new StringBuilder (32); var extensions = new StringBuilder (32);
if (_compression != CompressionMethod.NONE) if (_compression != CompressionMethod.None)
extensions.Append (_compression.ToExtensionString ()); extensions.Append (_compression.ToExtensionString ());
return extensions.Length > 0 return extensions.Length > 0
@ -997,7 +997,7 @@ namespace WebSocketSharp
private void init () private void init ()
{ {
_compression = CompressionMethod.NONE; _compression = CompressionMethod.None;
_cookies = new CookieCollection (); _cookies = new CookieCollection ();
_forConn = new object (); _forConn = new object ();
_forSend = new object (); _forSend = new object ();
@ -1073,7 +1073,7 @@ namespace WebSocketSharp
var sent = false; var sent = false;
try { try {
var compressed = false; var compressed = false;
if (_compression != CompressionMethod.NONE) { if (_compression != CompressionMethod.None) {
data = data.Compress (_compression); data = data.Compress (_compression);
compressed = true; compressed = true;
} }
@ -1097,7 +1097,7 @@ namespace WebSocketSharp
var src = stream; var src = stream;
var compressed = false; var compressed = false;
try { try {
if (_compression != CompressionMethod.NONE) { if (_compression != CompressionMethod.None) {
stream = stream.Compress (_compression); stream = stream.Compress (_compression);
compressed = true; compressed = true;
} }
@ -1293,10 +1293,10 @@ namespace WebSocketSharp
// As client // As client
private bool validateSecWebSocketExtensionsHeader (string value) private bool validateSecWebSocketExtensionsHeader (string value)
{ {
var compress = _compression != CompressionMethod.NONE ? true : false; var compress = _compression != CompressionMethod.None;
if (value == null || value.Length == 0) { if (value == null || value.Length == 0) {
if (compress) if (compress)
_compression = CompressionMethod.NONE; _compression = CompressionMethod.None;
return true; return true;
} }
@ -1447,7 +1447,7 @@ namespace WebSocketSharp
opcode, opcode,
Mask.Unmask, Mask.Unmask,
data.Compress (_compression), data.Compress (_compression),
_compression != CompressionMethod.NONE) _compression != CompressionMethod.None)
.ToByteArray (); .ToByteArray ();
cache.Add (_compression, cached); cache.Add (_compression, cached);
@ -1477,7 +1477,7 @@ namespace WebSocketSharp
cached.Position = 0; cached.Position = 0;
if (_readyState == WebSocketState.OPEN) if (_readyState == WebSocketState.OPEN)
sendFragmented (opcode, cached, Mask.Unmask, _compression != CompressionMethod.NONE); sendFragmented (opcode, cached, Mask.Unmask, _compression != CompressionMethod.None);
} }
catch (Exception ex) { catch (Exception ex) {
_logger.Fatal (ex.ToString ()); _logger.Fatal (ex.ToString ());
@ -1850,7 +1850,7 @@ namespace WebSocketSharp
if (len <= FragmentLength) if (len <= FragmentLength)
send ( send (
Opcode.BINARY, Opcode.BINARY,
len > 0 && _client && _compression == CompressionMethod.NONE ? data.Copy (len) : data); len > 0 && _client && _compression == CompressionMethod.None ? data.Copy (len) : data);
else else
send (Opcode.BINARY, new MemoryStream (data)); send (Opcode.BINARY, new MemoryStream (data));
} }
@ -1926,7 +1926,7 @@ namespace WebSocketSharp
if (len <= FragmentLength) if (len <= FragmentLength)
sendAsync ( sendAsync (
Opcode.BINARY, Opcode.BINARY,
len > 0 && _client && _compression == CompressionMethod.NONE ? data.Copy (len) : data, len > 0 && _client && _compression == CompressionMethod.None ? data.Copy (len) : data,
completed); completed);
else else
sendAsync (Opcode.BINARY, new MemoryStream (data), completed); sendAsync (Opcode.BINARY, new MemoryStream (data), completed);

Loading…
Cancel
Save