Modified CompressionMethod enum values to PascalCase values
This commit is contained in:
parent
639b056f1a
commit
e594696a38
@ -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) =>
|
||||
//{
|
||||
|
@ -123,7 +123,7 @@ namespace Example1
|
||||
);
|
||||
};
|
||||
|
||||
//_ws.Compression = CompressionMethod.DEFLATE;
|
||||
//_ws.Compression = CompressionMethod.Deflate;
|
||||
|
||||
_notifyMsgState = new ThreadState();
|
||||
_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.
|
||||
|
||||
```cs
|
||||
ws.Compression = CompressionMethod.DEFLATE;
|
||||
ws.Compression = CompressionMethod.Deflate;
|
||||
```
|
||||
|
||||
And then your client sends the following header with the connection request to the server.
|
||||
|
@ -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
|
||||
{
|
||||
/// <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>
|
||||
/// <remarks>
|
||||
/// The <b>CompressionMethod</b> enumeration contains the values of the compression methods defined in
|
||||
/// <see href="http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-09">Compression Extensions for WebSocket</see>.
|
||||
/// The compression methods are defined in
|
||||
/// <see href="http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-09">Compression
|
||||
/// Extensions for WebSocket</see>.
|
||||
/// </remarks>
|
||||
public enum CompressionMethod : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates non compression.
|
||||
/// </summary>
|
||||
NONE,
|
||||
None,
|
||||
/// <summary>
|
||||
/// Indicates using DEFLATE.
|
||||
/// </summary>
|
||||
DEFLATE
|
||||
Deflate
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ namespace WebSocketSharp
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// 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>
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user