Fix for the deflate frame

This commit is contained in:
sta
2013-04-23 18:08:42 +09:00
parent df1ff81483
commit b33b5e63ba
81 changed files with 1204 additions and 347 deletions

View File

@@ -0,0 +1,52 @@
#region License
/*
* CompressionMethod.cs
*
* The MIT License
*
* Copyright (c) 2013 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
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#endregion
using System;
namespace WebSocketSharp {
/// <summary>
/// Contains the values of the compression methods used to compress the payload data of the WebSocket Data frame.
/// </summary>
/// <remarks>
/// The <b>CompressionMethod</b> enumeration contains the values of the compression methods defined in
/// <see href="http://tools.ietf.org/html/draft-tyoshino-hybi-permessage-compression-00">WebSocket Per-message Compression</see>
/// specification for a WebSocket extension.
/// </remarks>
public enum CompressionMethod : byte
{
/// <summary>
/// Indicates non compression.
/// </summary>
NONE,
/// <summary>
/// Indicates using DEFLATE.
/// </summary>
DEFLATE
}
}

View File

@@ -115,14 +115,60 @@ namespace WebSocketSharp {
internal static bool IsToken(this string value)
{
foreach (char c in value)
{
if (c < 0x20 || c >= 0x7f || _tspecials.Contains(c))
return false;
}
return true;
}
internal static string Quote(this string value)
{
return value.IsToken()
? value
: String.Format("\"{0}\"", value.Replace("\"", "\\\""));
}
internal static IEnumerable<string> SplitHeaderValue(this string value, params char[] separator)
{
var separators = new string(separator);
var buffer = new StringBuilder(64);
int len = value.Length;
bool quoted = false;
bool escaped = false;
for (int i = 0; i < len; i++)
{
char c = value[i];
if (c == '"')
{
if (escaped)
escaped = !escaped;
else
quoted = !quoted;
}
else if (c == '\\')
{
if (i < len - 1 && value[i + 1] == '"')
escaped = true;
}
else if (separators.Contains(c))
{
if (!quoted)
{
yield return buffer.ToString();
buffer.Length = 0;
continue;
}
}
else {
}
buffer.Append(c);
}
if (buffer.Length > 0)
yield return buffer.ToString();
}
#endregion
#region Public Methods
@@ -547,17 +593,17 @@ namespace WebSocketSharp {
}
/// <summary>
/// Determines whether the specified <see cref="string"/> is a <see cref="String.Empty"/>.
/// Determines whether the specified <see cref="string"/> is empty.
/// </summary>
/// <returns>
/// <c>true</c> if <paramref name="value"/> is <see cref="String.Empty"/>; otherwise, <c>false</c>.
/// <c>true</c> if <paramref name="value"/> is empty; otherwise, <c>false</c>.
/// </returns>
/// <param name="value">
/// A <see cref="string"/> to test.
/// </param>
public static bool IsEmpty(this string value)
{
return value == String.Empty ? true : false;
return value.Length == 0;
}
/// <summary>
@@ -628,18 +674,18 @@ namespace WebSocketSharp {
/// Determines whether the specified object is <see langword="null"/>.
/// </summary>
/// <returns>
/// <c>true</c> if the <paramref name="obj"/> parameter is <see langword="null"/>; otherwise, <c>false</c>.
/// <c>true</c> if <paramref name="obj"/> is <see langword="null"/>; otherwise, <c>false</c>.
/// </returns>
/// <param name="obj">
/// A <b>class</b> to test.
/// An <b>object</b> to test.
/// </param>
/// <typeparam name="T">
/// The type of the <paramref name="obj"/> parameter.
/// The type of <paramref name="obj"/> parameter.
/// </typeparam>
public static bool IsNull<T>(this T obj)
where T : class
{
return obj == null ? true : false;
return obj == null;
}
/// <summary>
@@ -671,17 +717,17 @@ namespace WebSocketSharp {
}
/// <summary>
/// Determines whether the specified <see cref="string"/> is <see langword="null"/> or <see cref="String.Empty"/>.
/// Determines whether the specified <see cref="string"/> is <see langword="null"/> or empty.
/// </summary>
/// <returns>
/// <c>true</c> if the <paramref name="value"/> parameter is <see langword="null"/> or <see cref="String.Empty"/>; otherwise, <c>false</c>.
/// <c>true</c> if the <paramref name="value"/> parameter is <see langword="null"/> or empty; otherwise, <c>false</c>.
/// </returns>
/// <param name="value">
/// A <see cref="string"/> to test.
/// </param>
public static bool IsNullOrEmpty(this string value)
{
return String.IsNullOrEmpty(value);
return value.IsNull() || value.IsEmpty();
}
/// <summary>

View File

@@ -68,7 +68,7 @@ namespace WebSocketSharp {
/// </value>
public string Data {
get {
return ((Opcode.TEXT | Opcode.PING | Opcode.PONG) & _type) == _type
return _type == Opcode.TEXT || _type == Opcode.PING || _type == Opcode.PONG
? _data.Length > 0
? Encoding.UTF8.GetString(_data.ToByteArray())
: String.Empty

View File

@@ -549,15 +549,6 @@ namespace WebSocketSharp.Net {
return i ^ (j << 13 | j >> 19) ^ (k << 26 | k >> 6) ^ (l << 7 | l >> 25) ^ (m << 20 | m >> 12);
}
// See para 3.6 of RFC 2616
string Quote (string value)
{
if (version == 0 || value.IsToken ())
return value;
else
return "\"" + value.Replace("\"", "\\\"") + "\"";
}
string ToResponseStringVersion0 ()
{
var result = new StringBuilder (64);
@@ -605,7 +596,7 @@ namespace WebSocketSharp.Net {
result.AppendFormat ("; Comment={0}", comment.UrlEncode ());
if (!commentUri.IsNull ())
result.AppendFormat ("; CommentURL={0}", Quote (commentUri.OriginalString));
result.AppendFormat ("; CommentURL={0}", commentUri.OriginalString.Quote ());
if (discard)
result.Append ("; Discard");

View File

@@ -401,37 +401,7 @@ namespace WebSocketSharp.Net {
static IEnumerable<string> Split (string value)
{
var buffer = new StringBuilder (64);
int len = value.Length;
bool quoted = false;
bool escaped = false;
for (int i = 0; i < len; i++) {
char c = value [i];
if (c == '"') {
if (escaped)
escaped = !escaped;
else
quoted = !quoted;
}
else if (c == '\\') {
if (i < len - 1 && value [i + 1] == '"')
escaped = true;
}
else if (c == ',' || c == ';') {
if (!quoted) {
yield return buffer.ToString ();
buffer.Length = 0;
continue;
}
}
else {
}
buffer.Append (c);
}
if (buffer.Length > 0)
yield return buffer.ToString ();
return value.SplitHeaderValue (',', ';');
}
#endregion

View File

@@ -37,7 +37,6 @@ namespace WebSocketSharp {
/// The <b>Opcode</b> enumeration contains the values of the opcodes defined in
/// <see href="http://tools.ietf.org/html/rfc6455#section-5.2">RFC 6455</see> for the WebSocket protocol.
/// </remarks>
[Flags]
public enum Opcode : byte
{
/// <summary>

View File

@@ -29,6 +29,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
@@ -126,6 +128,48 @@ namespace WebSocketSharp {
#region Private Methods
private static byte[] compress(byte[] value)
{
if (value.LongLength == 0)
//return new Byte[] { 0x00, 0x00, 0x00, 0xff, 0xff };
return value;
using (var comp = new MemoryStream())
using (var ds = new DeflateStream(comp, CompressionMode.Compress, true))
{
ds.Write(value, 0, value.Length);
ds.Close(); // "BFINAL" set to 1.
comp.Close();
return comp.ToArray();
}
}
private static byte[] decompress(byte[] value)
{
if (value.LongLength == 0)
return value;
using (var decomp = new MemoryStream())
using (var comp = new MemoryStream(value))
using (var ds = new DeflateStream(comp, CompressionMode.Decompress, true))
{
int readLen = 0;
var buffer = new byte[256];
while (true)
{
readLen = ds.Read(buffer, 0, buffer.Length);
if (readLen == 0)
break;
decomp.Write(buffer, 0, readLen);
}
decomp.Close();
return decomp.ToArray();
}
}
private static void mask(byte[] src, byte[] key)
{
for (long i = 0; i < src.LongLength; i++)
@@ -134,6 +178,50 @@ namespace WebSocketSharp {
#endregion
#region Internal Methods
internal bool Compress(CompressionMethod method)
{
try
{
if (ExtensionData.LongLength > 0)
return false;
if (method == CompressionMethod.DEFLATE)
ApplicationData = compress(ApplicationData);
else
return false;
return true;
}
catch
{
return false;
}
}
internal bool Decompress(CompressionMethod method)
{
try
{
if (ApplicationData.LongLength == 0)
return true;
if (method == CompressionMethod.DEFLATE)
ApplicationData = decompress(ApplicationData);
else
return false;
return true;
}
catch
{
return false;
}
}
#endregion
#region Public Methods
public IEnumerator<byte> GetEnumerator()

View File

@@ -63,26 +63,45 @@ namespace WebSocketSharp {
#endregion
#region Private Static Fields
private static NameValueCollection _extensionsReg;
#endregion
#region Private Fields
private string _base64key;
private bool _client;
private Action _closeContext;
private CookieCollection _cookies;
private WebSocketContext _context;
private string _extensions;
private AutoResetEvent _exitReceiving;
private Object _forClose;
private Object _forSend;
private string _origin;
private string _protocol;
private string _protocols;
private volatile WsState _readyState;
private AutoResetEvent _receivePong;
private bool _secure;
private TcpClient _tcpClient;
private Uri _uri;
private WsStream _wsStream;
private string _base64key;
private bool _client;
private Action _closeContext;
private CookieCollection _cookies;
private CompressionMethod _compression;
private WebSocketContext _context;
private string _extensions;
private AutoResetEvent _exitReceiving;
private Object _forClose;
private Object _forSend;
private string _origin;
private string _protocol;
private string _protocols;
private volatile WsState _readyState;
private AutoResetEvent _receivePong;
private bool _secure;
private TcpClient _tcpClient;
private Uri _uri;
private WsStream _wsStream;
#endregion
#region Static Constructor
static WebSocket()
{
_extensionsReg = new NameValueCollection();
_extensionsReg.Add("deflate", "deflate-frame");
_extensionsReg.Add("deflate", "perframe-compress; method=deflate");
_extensionsReg.Add("deflate", "permessage-compress; method=deflate");
}
#endregion
@@ -90,12 +109,13 @@ namespace WebSocketSharp {
private WebSocket()
{
_cookies = new CookieCollection();
_compression = CompressionMethod.NONE;
_cookies = new CookieCollection();
_extensions = String.Empty;
_forClose = new Object();
_forSend = new Object();
_origin = String.Empty;
_protocol = String.Empty;
_forClose = new Object();
_forSend = new Object();
_origin = String.Empty;
_protocol = String.Empty;
_readyState = WsState.CONNECTING;
}
@@ -220,6 +240,26 @@ namespace WebSocketSharp {
#region Public Properties
/// <summary>
/// Gets or sets the compression method used to compress the payload data of the WebSocket Data frame.
/// </summary>
/// <value>
/// One of the <see cref="CompressionMethod"/> values that indicates the compression method to use.
/// The default is <see cref="CompressionMethod.NONE"/>.
/// </value>
public CompressionMethod Compression {
get {
return _compression;
}
set {
if (isOpened(true))
return;
_compression = value;
}
}
/// <summary>
/// Gets the cookies used in the WebSocket opening handshake.
/// </summary>
@@ -238,11 +278,10 @@ namespace WebSocketSharp {
}
/// <summary>
/// Gets the extensions selected by the server.
/// Gets the WebSocket extensions selected by the server.
/// </summary>
/// <value>
/// A <see cref="string"/> that contains the extensions if any. The default is <see cref="String.Empty"/>.
/// (Currently this will only ever be the <see cref="String.Empty"/>.)
/// </value>
public string Extensions {
get {
@@ -251,7 +290,7 @@ namespace WebSocketSharp {
}
/// <summary>
/// Gets a value indicating whether a connection is alive.
/// Gets a value indicating whether the WebSocket connection is alive.
/// </summary>
/// <value>
/// <c>true</c> if the connection is alive; otherwise, <c>false</c>.
@@ -266,7 +305,7 @@ namespace WebSocketSharp {
}
/// <summary>
/// Gets a value indicating whether a connection is secure.
/// Gets a value indicating whether the WebSocket connection is secure.
/// </summary>
/// <value>
/// <c>true</c> if the connection is secure; otherwise, <c>false</c>.
@@ -299,30 +338,31 @@ namespace WebSocketSharp {
}
set {
var origin = value.ToUri();
var msg = _readyState == WsState.OPEN
? "The WebSocket connection has been established already."
: !origin.IsNull() && (!origin.IsAbsoluteUri || origin.Segments.Length > 1)
? "The syntax of value must be '<scheme>://<host>[:<port>]'."
: String.Empty;
if (isOpened(true))
return;
if (!msg.IsEmpty())
if (value.IsNullOrEmpty())
{
onError(msg);
_origin = String.Empty;
return;
}
_origin = origin.IsNull()
? String.Empty
: value.TrimEnd('/');
var origin = new Uri(value);
if (!origin.IsAbsoluteUri || origin.Segments.Length > 1)
{
onError("The syntax of value must be '<scheme>://<host>[:<port>]'.");
return;
}
_origin = value.TrimEnd('/');
}
}
/// <summary>
/// Gets the subprotocol selected by the server.
/// Gets the WebSocket subprotocol selected by the server.
/// </summary>
/// <value>
/// A <see cref="string"/> that contains the subprotocol if any. By default, <c>String.Empty</c>.
/// A <see cref="string"/> that contains the subprotocol if any. The default is <see cref="String.Empty"/>.
/// </value>
public string Protocol {
get {
@@ -331,10 +371,10 @@ namespace WebSocketSharp {
}
/// <summary>
/// Gets the state of the connection.
/// Gets the state of the WebSocket connection.
/// </summary>
/// <value>
/// One of the <see cref="WebSocketSharp.WsState"/>. By default, <c>WsState.CONNECTING</c>.
/// One of the <see cref="WebSocketSharp.WsState"/> values. The default is <see cref="WsState.CONNECTING"/>.
/// </value>
public WsState ReadyState {
get {
@@ -343,10 +383,10 @@ namespace WebSocketSharp {
}
/// <summary>
/// Gets the WebSocket URL.
/// Gets the WebSocket URL to connect.
/// </summary>
/// <value>
/// A <see cref="Uri"/> that contains the WebSocket URL.
/// A <see cref="Uri"/> that contains the WebSocket URL to connect.
/// </value>
public Uri Url {
get {
@@ -397,15 +437,6 @@ namespace WebSocketSharp {
return true;
}
private void close(HttpStatusCode code)
{
if (_readyState != WsState.CONNECTING || _client)
return;
sendResponseHandshake(code);
closeResources();
}
private void close(PayloadData data)
{
#if DEBUG
@@ -443,35 +474,45 @@ namespace WebSocketSharp {
#endif
}
private void close(CloseStatusCode code, string reason)
private void close(HttpStatusCode code)
{
close((ushort)code, reason);
if (_readyState != WsState.CONNECTING || _client)
return;
sendResponseHandshake(code);
closeResources();
}
private void close(ushort code, string reason)
{
var data = new List<byte>(code.ToByteArray(ByteOrder.BIG));
if (!reason.IsNullOrEmpty())
using (var buffer = new MemoryStream())
{
var buffer = Encoding.UTF8.GetBytes(reason);
data.AddRange(buffer);
}
var tmp = code.ToByteArray(ByteOrder.BIG);
buffer.Write(tmp, 0, tmp.Length);
if (!reason.IsNullOrEmpty())
{
tmp = Encoding.UTF8.GetBytes(reason);
buffer.Write(tmp, 0, tmp.Length);
}
var payloadData = new PayloadData(data.ToArray());
if (payloadData.Length > 125)
{
var msg = "A Close frame must have a payload length of 125 bytes or less.";
onError(msg);
return;
}
buffer.Close();
var data = buffer.ToArray();
if (data.Length > 125)
{
var msg = "The payload length of a Close frame must be 125 bytes or less.";
onError(msg);
close(payloadData);
return;
}
close(new PayloadData(data));
}
}
private void closeHandshake(PayloadData data)
{
var args = new CloseEventArgs(data);
var frame = createFrame(Fin.FINAL, Opcode.CLOSE, data);
var args = new CloseEventArgs(data);
var frame = createControlFrame(Opcode.CLOSE, data);
if (send(frame))
args.WasClean = true;
@@ -542,11 +583,41 @@ namespace WebSocketSharp {
return Convert.ToBase64String(src);
}
private WsFrame createFrame(Fin fin, Opcode opcode, PayloadData payloadData)
// As client
private string createCompressionExtension()
{
return _compression != CompressionMethod.NONE
//? "deflate-frame"
//? String.Format("perframe-compress; method={0}", _compression.ToString().ToLower())
? String.Format("permessage-compress; method={0}", _compression.ToString().ToLower())
: String.Empty;
}
private WsFrame createControlFrame(Opcode opcode, PayloadData payloadData)
{
return _client
? new WsFrame(fin, opcode, payloadData)
: new WsFrame(fin, opcode, Mask.UNMASK, payloadData);
? new WsFrame(opcode, Mask.MASK, payloadData)
: new WsFrame(opcode, Mask.UNMASK, payloadData);
}
private WsFrame createDataFrame(Fin fin, Opcode opcode, PayloadData payloadData)
{
return _client
? new WsFrame(fin, opcode, Mask.MASK, payloadData, _compression)
: new WsFrame(fin, opcode, Mask.UNMASK, payloadData, _compression);
}
// As client
private string createRequestExtensions()
{
var extensions = new StringBuilder(64);
var compression = createCompressionExtension();
if (!compression.IsEmpty())
extensions.Append(compression);
return extensions.Length > 0
? extensions.ToString()
: String.Empty;
}
// As client
@@ -559,12 +630,21 @@ namespace WebSocketSharp {
var req = new RequestHandshake(path);
req.AddHeader("Host", host);
if (!_origin.IsEmpty())
req.AddHeader("Origin", _origin);
req.AddHeader("Sec-WebSocket-Key", _base64key);
if (!_protocols.IsNullOrEmpty())
req.AddHeader("Sec-WebSocket-Protocol", _protocols);
var extensions = createRequestExtensions();
if (!extensions.IsEmpty())
req.AddHeader("Sec-WebSocket-Extensions", extensions);
req.AddHeader("Sec-WebSocket-Version", _version);
if (_cookies.Count > 0)
req.SetCookies(_cookies);
@@ -576,6 +656,9 @@ namespace WebSocketSharp {
{
var res = new ResponseHandshake();
res.AddHeader("Sec-WebSocket-Accept", createResponseKey());
if (!_extensions.IsEmpty())
res.AddHeader("Sec-WebSocket-Extensions", _extensions);
if (_cookies.Count > 0)
res.SetCookies(_cookies);
@@ -630,14 +713,36 @@ namespace WebSocketSharp {
}
// As client
private bool isValid(ResponseHandshake response)
private bool isCompressionExtension(string value)
{
return !response.IsWebSocketResponse
? false
: !response.HeaderExists("Sec-WebSocket-Accept", createResponseKey())
? false
: !response.HeaderExists("Sec-WebSocket-Version") ||
response.HeaderExists("Sec-WebSocket-Version", _version);
var expected = createCompressionExtension();
return !expected.IsEmpty()
? value.Equals(expected)
: false;
}
// As server
private bool isDeflateExtension(string value)
{
if (value.StartsWith("x-webkit-"))
value = value.Substring(9);
foreach (var deflate in _extensionsReg.GetValues("deflate"))
if (value.Equals(deflate))
return true;
return false;
}
private bool isOpened(bool errorIfOpened)
{
if (_readyState != WsState.OPEN && _readyState != WsState.CLOSING)
return false;
if (errorIfOpened)
onError("The WebSocket connection has been established already.");
return true;
}
// As server
@@ -670,6 +775,17 @@ namespace WebSocketSharp {
: _context.Headers.Exists("Sec-WebSocket-Version", _version);
}
// As client
private bool isValidResponseHandshake(ResponseHandshake response)
{
return !response.IsWebSocketResponse
? false
: !response.HeaderExists("Sec-WebSocket-Accept", createResponseKey())
? false
: !response.HeaderExists("Sec-WebSocket-Version") ||
response.HeaderExists("Sec-WebSocket-Version", _version);
}
private void onClose(CloseEventArgs eventArgs)
{
if (!Thread.CurrentThread.IsBackground)
@@ -710,12 +826,13 @@ namespace WebSocketSharp {
var buffer = Encoding.UTF8.GetBytes(message);
if (buffer.Length > 125)
{
var msg = "A Ping frame must have a payload length of 125 bytes or less.";
var msg = "The payload length of a Ping frame must be 125 bytes or less.";
onError(msg);
return false;
}
if (!send(Fin.FINAL, Opcode.PING, buffer))
var frame = createControlFrame(Opcode.PING, new PayloadData(buffer));
if (!send(frame))
return false;
return _receivePong.WaitOne(millisecondsTimeout);
@@ -723,7 +840,7 @@ namespace WebSocketSharp {
private void pong(PayloadData data)
{
var frame = createFrame(Fin.FINAL, Opcode.PONG, data);
var frame = createControlFrame(Opcode.PONG, data);
send(frame);
}
@@ -733,19 +850,6 @@ namespace WebSocketSharp {
pong(payloadData);
}
private void process(WsFrame frame)
{
bool processed = processAbnormal(frame) ||
processFragmented(frame) ||
processData(frame) ||
processPing(frame) ||
processPong(frame) ||
processClose(frame);
if (!processed)
processIncorrectFrame();
}
private bool processAbnormal(WsFrame frame)
{
if (!frame.IsNull())
@@ -755,14 +859,14 @@ namespace WebSocketSharp {
Console.WriteLine("WS: Info@processAbnormal: Start closing handshake.");
#endif
var msg = "What we've got here is a failure to communicate in the WebSocket protocol.";
close(CloseStatusCode.ABNORMAL, msg);
Close(CloseStatusCode.ABNORMAL, msg);
return true;
}
private bool processClose(WsFrame frame)
{
if (frame.Opcode != Opcode.CLOSE)
if (!frame.IsClose)
return false;
#if DEBUG
@@ -778,6 +882,12 @@ namespace WebSocketSharp {
if (!frame.IsData)
return false;
if (frame.IsCompressed && _compression == CompressionMethod.NONE)
return false;
if (frame.IsCompressed)
frame.Decompress(_compression);
onMessage(new MessageEventArgs(frame.Opcode, frame.PayloadData));
return true;
}
@@ -785,15 +895,15 @@ namespace WebSocketSharp {
private bool processFragmented(WsFrame frame)
{
// Not first fragment
if (frame.Opcode == Opcode.CONT)
if (frame.IsContinuation)
return true;
// Not fragmented
if (frame.Fin == Fin.FINAL)
if (frame.IsFinal)
return false;
// First fragment
if (frame.IsData)
if (frame.IsData && !(frame.IsCompressed && _compression == CompressionMethod.NONE))
processFragments(frame);
else
processIncorrectFrame();
@@ -803,48 +913,55 @@ namespace WebSocketSharp {
private void processFragments(WsFrame first)
{
bool compressed = first.IsCompressed;
if (compressed)
first.Decompress(_compression);
var buffer = new List<byte>(first.PayloadData.ToByteArray());
Func<WsFrame, bool> processContinuation = contFrame =>
{
if (!contFrame.IsContinuation)
return false;
if (compressed)
contFrame.Decompress(_compression);
buffer.AddRange(contFrame.PayloadData.ToByteArray());
return true;
};
while (true)
{
var frame = readFrame();
if (processAbnormal(frame))
return;
// MORE
if (frame.Fin == Fin.MORE)
if (!frame.IsFinal)
{
// MORE & CONT
if (frame.Opcode == Opcode.CONT)
{
buffer.AddRange(frame.PayloadData.ToByteArray());
if (processContinuation(frame))
continue;
}
// MORE & ?
processIncorrectFrame();
return;
}
// FINAL & CONT
if (frame.Opcode == Opcode.CONT)
else
{
buffer.AddRange(frame.PayloadData.ToByteArray());
break;
// FINAL & CONT
if (processContinuation(frame))
break;
// FINAL & PING
if (processPing(frame))
continue;
// FINAL & PONG
if (processPong(frame))
continue;
// FINAL & CLOSE
if (processClose(frame))
return;
}
// FINAL & PING
if (processPing(frame))
continue;
// FINAL & PONG
if (processPong(frame))
continue;
// FINAL & CLOSE
if (processClose(frame))
return;
// FINAL & ?
// ?
processIncorrectFrame();
return;
}
@@ -852,17 +969,30 @@ namespace WebSocketSharp {
onMessage(new MessageEventArgs(first.Opcode, new PayloadData(buffer.ToArray())));
}
private void processFrame(WsFrame frame)
{
bool processed = processAbnormal(frame) ||
processFragmented(frame) ||
processData(frame) ||
processPing(frame) ||
processPong(frame) ||
processClose(frame);
if (!processed)
processIncorrectFrame();
}
private void processIncorrectFrame()
{
#if DEBUG
Console.WriteLine("WS: Info@processIncorrectFrame: Start closing handshake.");
#endif
close(CloseStatusCode.INCORRECT_DATA, String.Empty);
Close(CloseStatusCode.INCORRECT_DATA);
}
private bool processPing(WsFrame frame)
{
if (frame.Opcode != Opcode.PING)
if (!frame.IsPing)
return false;
#if DEBUG
@@ -875,7 +1005,7 @@ namespace WebSocketSharp {
private bool processPong(WsFrame frame)
{
if (frame.Opcode != Opcode.PONG)
if (!frame.IsPong)
return false;
#if DEBUG
@@ -886,6 +1016,31 @@ namespace WebSocketSharp {
return true;
}
// As server
private void processRequestExtensions(string extensions)
{
if (extensions.IsNullOrEmpty())
return;
bool deflate = false;
var buffer = new StringBuilder(64);
foreach (var extension in extensions.SplitHeaderValue(','))
{
var tmp = extension.Trim();
if (!deflate && isDeflateExtension(tmp))
{
buffer.Append(tmp);
deflate = true;
}
}
if (deflate)
_compression = CompressionMethod.DEFLATE;
if (buffer.Length > 0)
_extensions = buffer.ToString();
}
// As server
private bool processRequestHandshake()
{
@@ -902,39 +1057,73 @@ namespace WebSocketSharp {
}
_base64key = _context.SecWebSocketKey;
if (_context.Headers.Exists("Sec-WebSocket-Protocol"))
_protocols = _context.Headers["Sec-WebSocket-Protocol"];
if (_context.Headers.Exists("Sec-WebSocket-Extensions"))
_extensions = _context.Headers["Sec-WebSocket-Extensions"];
processRequestProtocols(_context.Headers["Sec-WebSocket-Protocol"]);
processRequestExtensions(_context.Headers["Sec-WebSocket-Extensions"]);
return true;
}
// As server
private void processRequestProtocols(string protocols)
{
if (!protocols.IsNullOrEmpty())
_protocols = protocols;
}
// As client
private void processResponseCookies(CookieCollection cookies)
{
if (cookies.Count > 0)
_cookies.SetOrRemove(cookies);
}
// As client
private void processResponseExtensions(string extensions)
{
bool compress = false;
if (!extensions.IsNullOrEmpty())
{
foreach (var extension in extensions.SplitHeaderValue(','))
{
var tmp = extension.Trim();
if (!compress && isCompressionExtension(tmp))
compress = true;
}
_extensions = extensions;
}
if (!compress)
_compression = CompressionMethod.NONE;
}
// As client
private bool processResponseHandshake()
{
var res = receiveResponseHandshake();
if (!isValid(res))
if (!isValidResponseHandshake(res))
{
var msg = "Invalid response to this WebSocket connection request.";
onError(msg);
close(CloseStatusCode.ABNORMAL, msg);
Close(CloseStatusCode.ABNORMAL, msg);
return false;
}
if (res.HeaderExists("Sec-WebSocket-Protocol"))
_protocol = res.Headers["Sec-WebSocket-Protocol"];
if (res.HeaderExists("Sec-WebSocket-Extensions"))
_extensions = res.Headers["Sec-WebSocket-Extensions"];
if (res.Cookies.Count > 0)
_cookies.SetOrRemove(res.Cookies);
processResponseProtocol(res.Headers["Sec-WebSocket-Protocol"]);
processResponseExtensions(res.Headers["Sec-WebSocket-Extensions"]);
processResponseCookies(res.Cookies);
return true;
}
// As client
private void processResponseProtocol(string protocol)
{
if (!protocol.IsNullOrEmpty())
_protocol = protocol;
}
private WsFrame readFrame()
{
return _wsStream.ReadFrame();
@@ -978,8 +1167,7 @@ namespace WebSocketSharp {
private bool send(WsFrame frame)
{
if (_readyState == WsState.CONNECTING ||
_readyState == WsState.CLOSED)
if (!isOpened(false))
{
onError("The WebSocket connection isn't established or has been closed.");
return false;
@@ -1035,7 +1223,7 @@ namespace WebSocketSharp {
private bool send(Fin fin, Opcode opcode, byte[] data)
{
var frame = createFrame(fin, opcode, new PayloadData(data));
var frame = createDataFrame(fin, opcode, new PayloadData(data));
return send(frame);
}
@@ -1138,7 +1326,7 @@ namespace WebSocketSharp {
{
try
{
process(frame);
processFrame(frame);
if (_readyState == WsState.OPEN)
_wsStream.ReadFrameAsync(completed);
else
@@ -1146,11 +1334,11 @@ namespace WebSocketSharp {
}
catch (WsReceivedTooBigMessageException ex)
{
close(CloseStatusCode.TOO_BIG, ex.Message);
Close(CloseStatusCode.TOO_BIG, ex.Message);
}
catch (Exception)
{
close(CloseStatusCode.ABNORMAL, "An exception has occured.");
Close(CloseStatusCode.ABNORMAL, "An exception has occured.");
}
};
@@ -1176,8 +1364,7 @@ namespace WebSocketSharp {
/// </summary>
public void Close()
{
var data = new PayloadData(new byte[]{});
close(data);
close(new PayloadData());
}
/// <summary>
@@ -1185,8 +1372,8 @@ namespace WebSocketSharp {
/// releases all associated resources.
/// </summary>
/// <remarks>
/// Emits a <see cref="OnError"/> event if <paramref name="code"/> is not in the allowable range of
/// the WebSocket close status code, and do nothing any more.
/// This Close method emits a <see cref="OnError"/> event if <paramref name="code"/> is not
/// in the allowable range of the WebSocket close status code.
/// </remarks>
/// <param name="code">
/// A <see cref="ushort"/> that indicates the status code for closure.
@@ -1205,16 +1392,16 @@ namespace WebSocketSharp {
/// </param>
public void Close(CloseStatusCode code)
{
close(code, String.Empty);
close((ushort)code, String.Empty);
}
/// <summary>
/// Closes the WebSocket connection with the specified <paramref name="code"/> and <paramref name="reason"/>, and
/// releases all associated resources.
/// Closes the WebSocket connection with the specified <paramref name="code"/> and
/// <paramref name="reason"/>, and releases all associated resources.
/// </summary>
/// <remarks>
/// Emits a <see cref="OnError"/> event if <paramref name="code"/> is not in the allowable range of
/// the WebSocket close status code, and do nothing any more.
/// This Close method emits a <see cref="OnError"/> event if <paramref name="code"/> is not
/// in the allowable range of the WebSocket close status code.
/// </remarks>
/// <param name="code">
/// A <see cref="ushort"/> that indicates the status code for closure.
@@ -1235,8 +1422,8 @@ namespace WebSocketSharp {
}
/// <summary>
/// Closes the WebSocket connection with the specified <paramref name="code"/> and <paramref name="reason"/>, and
/// releases all associated resources.
/// Closes the WebSocket connection with the specified <paramref name="code"/> and
/// <paramref name="reason"/>, and releases all associated resources.
/// </summary>
/// <param name="code">
/// One of the <see cref="CloseStatusCode"/> values that indicates the status code for closure.
@@ -1246,7 +1433,7 @@ namespace WebSocketSharp {
/// </param>
public void Close(CloseStatusCode code, string reason)
{
close(code, reason);
close((ushort)code, reason);
}
/// <summary>
@@ -1254,22 +1441,19 @@ namespace WebSocketSharp {
/// </summary>
public void Connect()
{
if (_readyState == WsState.OPEN)
{
Console.WriteLine("WS: Info@Connect: The WebSocket connection has been established already.");
if (isOpened(true))
return;
}
try
{
if (connect())
onOpen();
}
catch (Exception)
catch
{
var msg = "An exception has occured.";
onError(msg);
close(CloseStatusCode.ABNORMAL, msg);
Close(CloseStatusCode.ABNORMAL, msg);
}
}
@@ -1441,15 +1625,12 @@ namespace WebSocketSharp {
/// </param>
public void SetCookie(Cookie cookie)
{
var msg = _readyState == WsState.OPEN
? "The WebSocket connection has been established already."
: cookie.IsNull()
? "'cookie' must not be null."
: String.Empty;
if (isOpened(true))
return;
if (!msg.IsEmpty())
if (cookie.IsNull())
{
onError(msg);
onError("'cookie' must not be null.");
return;
}

View File

@@ -53,16 +53,22 @@ namespace WebSocketSharp {
#region Public Constructors
public WsFrame(Opcode opcode, PayloadData payloadData)
: this(Fin.FINAL, opcode, payloadData)
: this(opcode, Mask.MASK, payloadData)
{
}
public WsFrame(Fin fin, Opcode opcode, PayloadData payloadData)
: this(fin, opcode, Mask.MASK, payloadData)
public WsFrame(Opcode opcode, Mask mask, PayloadData payloadData)
: this(Fin.FINAL, opcode, mask, payloadData)
{
}
public WsFrame(Fin fin, Opcode opcode, Mask mask, PayloadData payloadData)
: this(fin, opcode, mask, payloadData, CompressionMethod.NONE)
{
}
public WsFrame(
Fin fin, Opcode opcode, Mask mask, PayloadData payloadData, CompressionMethod compress)
{
if (payloadData.IsNull())
throw new ArgumentNullException("payloadData");
@@ -74,10 +80,18 @@ namespace WebSocketSharp {
if (!isFinal(fin) && isControl(opcode))
throw new ArgumentException("The control frame must not be fragmented.");
if (isControl(opcode) && compress != CompressionMethod.NONE)
throw new ArgumentException("The control frame must not be compressed.");
Fin = fin;
Rsv1 = Rsv.OFF;
Rsv2 = Rsv.OFF;
Rsv3 = Rsv.OFF;
Opcode = opcode;
Mask = mask;
PayloadData = payloadData;
if (compress != CompressionMethod.NONE)
compressPayloadData(compress);
init();
}
@@ -86,6 +100,30 @@ namespace WebSocketSharp {
#region Internal Properties
internal bool IsBinary {
get {
return isBinary(Opcode);
}
}
internal bool IsClose {
get {
return isClose(Opcode);
}
}
internal bool IsCompressed {
get {
return Rsv1 == Rsv.ON;
}
}
internal bool IsContinuation {
get {
return isContinuation(Opcode);
}
}
internal bool IsControl {
get {
return isControl(Opcode);
@@ -104,12 +142,36 @@ namespace WebSocketSharp {
}
}
internal bool IsFragmented {
get {
return !IsFinal || IsContinuation;
}
}
internal bool IsMasked {
get {
return isMasked(Mask);
}
}
internal bool IsPing {
get {
return isPing(Opcode);
}
}
internal bool IsPong {
get {
return isPong(Opcode);
}
}
internal bool IsText {
get {
return isText(Opcode);
}
}
internal ulong Length {
get {
return 2 + (ulong)(ExtPayloadLen.Length + MaskingKey.Length) + PayloadData.Length;
@@ -144,6 +206,26 @@ namespace WebSocketSharp {
#region Private Methods
private bool compressPayloadData(CompressionMethod method)
{
if (!PayloadData.Compress(method))
return false;
if (IsData)
Rsv1 = Rsv.ON;
return true;
}
private bool decompressPayloadData(CompressionMethod method)
{
if (!PayloadData.Decompress(method))
return false;
Rsv1 = Rsv.OFF;
return true;
}
private static void dump(WsFrame frame)
{
var len = frame.Length;
@@ -216,10 +298,6 @@ namespace WebSocketSharp {
private void init()
{
Rsv1 = Rsv.OFF;
Rsv2 = Rsv.OFF;
Rsv3 = Rsv.OFF;
setPayloadLen(PayloadData.Length);
if (IsMasked)
maskPayloadData();
@@ -227,16 +305,29 @@ namespace WebSocketSharp {
MaskingKey = new byte[]{};
}
private static bool isBinary(Opcode opcode)
{
return opcode == Opcode.BINARY;
}
private static bool isClose(Opcode opcode)
{
return opcode == Opcode.CLOSE;
}
private static bool isContinuation(Opcode opcode)
{
return opcode == Opcode.CONT;
}
private static bool isControl(Opcode opcode)
{
Opcode control = Opcode.CLOSE | Opcode.PING | Opcode.PONG;
return (control & opcode) == opcode;
return isClose(opcode) || isPing(opcode) || isPong(opcode);
}
private static bool isData(Opcode opcode)
{
Opcode data = Opcode.TEXT | Opcode.BINARY;
return (data & opcode) == opcode;
return isText(opcode) || isBinary(opcode);
}
private static bool isFinal(Fin fin)
@@ -249,6 +340,21 @@ namespace WebSocketSharp {
return mask == Mask.MASK;
}
private static bool isPing(Opcode opcode)
{
return opcode == Opcode.PING;
}
private static bool isPong(Opcode opcode)
{
return opcode == Opcode.PONG;
}
private static bool isText(Opcode opcode)
{
return opcode == Opcode.TEXT;
}
private void maskPayloadData()
{
var key = new byte[4];
@@ -289,7 +395,7 @@ namespace WebSocketSharp {
var opcode = frame.Opcode;
var payloadData = frame.PayloadData.Length == 0
? String.Empty
: masked || ((Opcode.CONT | Opcode.BINARY | Opcode.CLOSE) & opcode) == opcode
: masked || frame.IsFragmented || frame.IsBinary || frame.IsClose
? BitConverter.ToString(frame.PayloadData.ToByteArray())
: Encoding.UTF8.GetString(frame.PayloadData.ToByteArray());
@@ -432,6 +538,26 @@ namespace WebSocketSharp {
ExtPayloadLen = length.ToByteArray(ByteOrder.BIG);
}
private void unmaskPayloadData()
{
PayloadData.Mask(MaskingKey);
Mask = Mask.UNMASK;
MaskingKey = new byte[]{};
}
#endregion
#region Internal Methods
internal void Decompress(CompressionMethod method)
{
if (Mask == Mask.MASK)
unmaskPayloadData();
if (decompressPayloadData(method))
setPayloadLen(PayloadData.Length);
}
#endregion
#region Public Methods

View File

@@ -252,10 +252,10 @@
</member>
<member name="M:WebSocketSharp.Ext.IsEmpty(System.String)">
<summary>
Determines whether the specified <see cref="T:System.String" /> is a <see cref="F:System.String.Empty" />.
Determines whether the specified <see cref="T:System.String" /> is empty.
</summary>
<returns>
<c>true</c> if <paramref name="value" /> is <see cref="F:System.String.Empty" />; otherwise, <c>false</c>.
<c>true</c> if <paramref name="value" /> is empty; otherwise, <c>false</c>.
</returns>
<param name="value">
A <see cref="T:System.String" /> to test.
@@ -305,13 +305,13 @@
Determines whether the specified object is <see langword="null" />.
</summary>
<returns>
<c>true</c> if the <paramref name="obj" /> parameter is <see langword="null" />; otherwise, <c>false</c>.
<c>true</c> if <paramref name="obj" /> is <see langword="null" />; otherwise, <c>false</c>.
</returns>
<param name="obj">
A <b>class</b> to test.
An <b>object</b> to test.
</param>
<typeparam name="T">
The type of the <paramref name="obj" /> parameter.
The type of <paramref name="obj" /> parameter.
</typeparam>
</member>
<member name="M:WebSocketSharp.Ext.IsNullDo``1(``0,System.Action)">
@@ -334,10 +334,10 @@
</member>
<member name="M:WebSocketSharp.Ext.IsNullOrEmpty(System.String)">
<summary>
Determines whether the specified <see cref="T:System.String" /> is <see langword="null" /> or <see cref="F:System.String.Empty" />.
Determines whether the specified <see cref="T:System.String" /> is <see langword="null" /> or empty.
</summary>
<returns>
<c>true</c> if the <paramref name="value" /> parameter is <see langword="null" /> or <see cref="F:System.String.Empty" />; otherwise, <c>false</c>.
<c>true</c> if the <paramref name="value" /> parameter is <see langword="null" /> or empty; otherwise, <c>false</c>.
</returns>
<param name="value">
A <see cref="T:System.String" /> to test.
@@ -942,6 +942,15 @@
Occurs when the WebSocket connection has been established.
</summary>
</member>
<member name="P:WebSocketSharp.WebSocket.Compression">
<summary>
Gets or sets the compression method used to compress the payload data of the WebSocket Data frame.
</summary>
<value>
One of the <see cref="T:WebSocketSharp.CompressionMethod" /> values that indicates the compression method to use.
The default is <see cref="F:WebSocketSharp.CompressionMethod.NONE" />.
</value>
</member>
<member name="P:WebSocketSharp.WebSocket.Cookies">
<summary>
Gets the cookies used in the WebSocket opening handshake.
@@ -953,16 +962,15 @@
</member>
<member name="P:WebSocketSharp.WebSocket.Extensions">
<summary>
Gets the extensions selected by the server.
Gets the WebSocket extensions selected by the server.
</summary>
<value>
A <see cref="T:System.String" /> that contains the extensions if any. The default is <see cref="F:System.String.Empty" />.
(Currently this will only ever be the <see cref="F:System.String.Empty" />.)
</value>
</member>
<member name="P:WebSocketSharp.WebSocket.IsAlive">
<summary>
Gets a value indicating whether a connection is alive.
Gets a value indicating whether the WebSocket connection is alive.
</summary>
<value>
<c>true</c> if the connection is alive; otherwise, <c>false</c>.
@@ -970,7 +978,7 @@
</member>
<member name="P:WebSocketSharp.WebSocket.IsSecure">
<summary>
Gets a value indicating whether a connection is secure.
Gets a value indicating whether the WebSocket connection is secure.
</summary>
<value>
<c>true</c> if the connection is secure; otherwise, <c>false</c>.
@@ -995,26 +1003,26 @@
</member>
<member name="P:WebSocketSharp.WebSocket.Protocol">
<summary>
Gets the subprotocol selected by the server.
Gets the WebSocket subprotocol selected by the server.
</summary>
<value>
A <see cref="T:System.String" /> that contains the subprotocol if any. By default, <c>String.Empty</c>.
A <see cref="T:System.String" /> that contains the subprotocol if any. The default is <see cref="F:System.String.Empty" />.
</value>
</member>
<member name="P:WebSocketSharp.WebSocket.ReadyState">
<summary>
Gets the state of the connection.
Gets the state of the WebSocket connection.
</summary>
<value>
One of the <see cref="T:WebSocketSharp.WsState" />. By default, <c>WsState.CONNECTING</c>.
One of the <see cref="T:WebSocketSharp.WsState" /> values. The default is <see cref="F:WebSocketSharp.WsState.CONNECTING" />.
</value>
</member>
<member name="P:WebSocketSharp.WebSocket.Url">
<summary>
Gets the WebSocket URL.
Gets the WebSocket URL to connect.
</summary>
<value>
A <see cref="T:System.Uri" /> that contains the WebSocket URL.
A <see cref="T:System.Uri" /> that contains the WebSocket URL to connect.
</value>
</member>
<member name="M:WebSocketSharp.WebSocket.Close">
@@ -1028,8 +1036,8 @@
releases all associated resources.
</summary>
<remarks>
Emits a <see cref="E:WebSocketSharp.WebSocket.OnError" /> event if <paramref name="code" /> is not in the allowable range of
the WebSocket close status code, and do nothing any more.
This Close method emits a <see cref="E:WebSocketSharp.WebSocket.OnError" /> event if <paramref name="code" /> is not
in the allowable range of the WebSocket close status code.
</remarks>
<param name="code">
A <see cref="T:System.UInt16" /> that indicates the status code for closure.
@@ -1046,12 +1054,12 @@
</member>
<member name="M:WebSocketSharp.WebSocket.Close(System.UInt16,System.String)">
<summary>
Closes the WebSocket connection with the specified <paramref name="code" /> and <paramref name="reason" />, and
releases all associated resources.
Closes the WebSocket connection with the specified <paramref name="code" /> and
<paramref name="reason" />, and releases all associated resources.
</summary>
<remarks>
Emits a <see cref="E:WebSocketSharp.WebSocket.OnError" /> event if <paramref name="code" /> is not in the allowable range of
the WebSocket close status code, and do nothing any more.
This Close method emits a <see cref="E:WebSocketSharp.WebSocket.OnError" /> event if <paramref name="code" /> is not
in the allowable range of the WebSocket close status code.
</remarks>
<param name="code">
A <see cref="T:System.UInt16" /> that indicates the status code for closure.
@@ -1062,8 +1070,8 @@
</member>
<member name="M:WebSocketSharp.WebSocket.Close(WebSocketSharp.CloseStatusCode,System.String)">
<summary>
Closes the WebSocket connection with the specified <paramref name="code" /> and <paramref name="reason" />, and
releases all associated resources.
Closes the WebSocket connection with the specified <paramref name="code" /> and
<paramref name="reason" />, and releases all associated resources.
</summary>
<param name="code">
One of the <see cref="T:WebSocketSharp.CloseStatusCode" /> values that indicates the status code for closure.
@@ -5170,5 +5178,25 @@
A <see cref="T:WebSocketSharp.Net.HttpListenerResponse" /> that contains the HTTP response objects.
</value>
</member>
<member name="T:WebSocketSharp.CompressionMethod">
<summary>
Contains the values of the compression methods used to compress the payload data of the WebSocket Data frame.
</summary>
<remarks>
The <b>CompressionMethod</b> enumeration contains the values of the compression methods defined in
<see href="http://tools.ietf.org/html/draft-tyoshino-hybi-permessage-compression-00">WebSocket Per-message Compression</see>
specification for a WebSocket extension.
</remarks>
</member>
<member name="F:WebSocketSharp.CompressionMethod.NONE">
<summary>
Indicates non compression.
</summary>
</member>
<member name="F:WebSocketSharp.CompressionMethod.DEFLATE">
<summary>
Indicates using DEFLATE.
</summary>
</member>
</members>
</doc>

View File

@@ -0,0 +1,258 @@
<html>
<head>
<title>WebSocketSharp.CompressionMethod</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
a { text-decoration: none }
div.SideBar {
padding-left: 1em;
padding-right: 1em;
right: 0;
float: right;
border: thin solid black;
background-color: #f2f2f2;
}
.CollectionTitle { font-weight: bold }
.PageTitle { font-size: 150%; font-weight: bold }
.Summary { }
.Signature { }
.Remarks { }
.Members { }
.Copyright { }
.Section { font-size: 125%; font-weight: bold }
p.Summary {
margin-left: 1em;
}
.SectionBox { margin-left: 2em }
.NamespaceName { font-size: 105%; font-weight: bold }
.NamespaceSumary { }
.MemberName { font-size: 115%; font-weight: bold; margin-top: 1em }
.Subsection { font-size: 105%; font-weight: bold }
.SubsectionBox { margin-left: 2em; margin-bottom: 1em }
.CodeExampleTable { background-color: #f5f5dd; border: thin solid black; padding: .25em; }
.TypesListing {
border-collapse: collapse;
}
td {
vertical-align: top;
}
th {
text-align: left;
}
.TypesListing td {
margin: 0px;
padding: .25em;
border: solid gray 1px;
}
.TypesListing th {
margin: 0px;
padding: .25em;
background-color: #f2f2f2;
border: solid gray 1px;
}
div.Footer {
border-top: 1px solid gray;
margin-top: 1.5em;
padding-top: 0.6em;
text-align: center;
color: gray;
}
span.NotEntered /* Documentation for this section has not yet been entered */ {
font-style: italic;
color: red;
}
div.Header {
background: #B0C4DE;
border: double;
border-color: white;
border-width: 7px;
padding: 0.5em;
}
div.Header * {
font-size: smaller;
}
div.Note {
}
i.ParamRef {
}
i.subtitle {
}
ul.TypeMembersIndex {
text-align: left;
background: #F8F8F8;
}
ul.TypeMembersIndex li {
display: inline;
margin: 0.5em;
}
table.HeaderTable {
}
table.SignatureTable {
}
table.Documentation, table.Enumeration, table.TypeDocumentation {
border-collapse: collapse;
width: 100%;
}
table.Documentation tr th, table.TypeMembers tr th, table.Enumeration tr th, table.TypeDocumentation tr th {
background: whitesmoke;
padding: 0.8em;
border: 1px solid gray;
text-align: left;
vertical-align: bottom;
}
table.Documentation tr td, table.TypeMembers tr td, table.Enumeration tr td, table.TypeDocumentation tr td {
padding: 0.5em;
border: 1px solid gray;
text-align: left;
vertical-align: top;
}
table.TypeMembers {
border: 1px solid #C0C0C0;
width: 100%;
}
table.TypeMembers tr td {
background: #F8F8F8;
border: white;
}
table.Documentation {
}
table.TypeMembers {
}
div.CodeExample {
width: 100%;
border: 1px solid #DDDDDD;
background-color: #F8F8F8;
}
div.CodeExample p {
margin: 0.5em;
border-bottom: 1px solid #DDDDDD;
}
div.CodeExample div {
margin: 0.5em;
}
h4 {
margin-bottom: 0;
}
div.Signature {
border: 1px solid #C0C0C0;
background: #F2F2F2;
padding: 1em;
}
</style>
<script type="text/JavaScript">
function toggle_display (block) {
var w = document.getElementById (block);
var t = document.getElementById (block + ":toggle");
if (w.style.display == "none") {
w.style.display = "block";
t.innerHTML = "⊟";
} else {
w.style.display = "none";
t.innerHTML = "⊞";
}
}
</script>
</head>
<body>
<div class="CollectionTitle">
<a href="../index.html">websocket-sharp</a> : <a href="index.html">WebSocketSharp Namespace</a></div>
<div class="SideBar">
<p>
<a href="#T:WebSocketSharp.CompressionMethod">Overview</a>
</p>
<p>
<a href="#T:WebSocketSharp.CompressionMethod:Signature">Signature</a>
</p>
<p>
<a href="#T:WebSocketSharp.CompressionMethod:Docs">Remarks</a>
</p>
<p>
<a href="#Members">Members</a>
</p>
<p>
<a href="#T:WebSocketSharp.CompressionMethod:Members">Member Details</a>
</p>
</div>
<h1 class="PageTitle" id="T:WebSocketSharp.CompressionMethod">CompressionMethod Enum</h1>
<p class="Summary" id="T:WebSocketSharp.CompressionMethod:Summary">
Contains the values of the compression methods used to compress the payload data of the WebSocket Data frame.
</p>
<div id="T:WebSocketSharp.CompressionMethod:Signature">
<h2>Syntax</h2>
<div class="Signature">public enum <b>CompressionMethod</b></div>
</div>
<div class="Remarks" id="T:WebSocketSharp.CompressionMethod:Docs">
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="T:WebSocketSharp.CompressionMethod:Docs:Remarks">
The CompressionMethod enumeration contains the values of the compression methods defined in
WebSocket Per-message Compression
specification for a WebSocket extension.
</div>
<h2 class="Section">Members</h2>
<div class="SectionBox" id="T:WebSocketSharp.CompressionMethod:Docs:Members">
<table class="Enumeration">
<tr>
<th>Member Name</th>
<th>Description</th>
</tr>
<tr valign="top">
<td id="F:WebSocketSharp.CompressionMethod.DEFLATE">
<b>DEFLATE</b>
</td>
<td>
Indicates using DEFLATE.
</td>
</tr>
<tr valign="top">
<td id="F:WebSocketSharp.CompressionMethod.NONE">
<b>NONE</b>
</td>
<td>
Indicates non compression.
</td>
</tr>
</table>
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="T:WebSocketSharp.CompressionMethod:Docs:Version Information">
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
</div>
<div class="Members" id="T:WebSocketSharp.CompressionMethod:Members">
</div>
<hr size="1" />
<div class="Copyright">
</div>
</body>
</html>

View File

@@ -418,7 +418,7 @@
<b>
<a href="#M:WebSocketSharp.Ext.IsEmpty(System.String)">IsEmpty</a>
</b>(<i>this</i> <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>)<nobr> : <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a></nobr><blockquote>
Determines whether the specified <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> is a <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>.
Determines whether the specified <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> is empty.
</blockquote></td>
</tr>
<tr valign="top">
@@ -461,7 +461,7 @@
<td colspan="2">
<b>
<a href="#M:WebSocketSharp.Ext.IsNull``1(``0)">IsNull&lt;T&gt;</a>
</b>(<i>this</i> <i title="&#xA; The type of the parameter.&#xA; ">T</i>)<nobr> : <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a></nobr><blockquote>
</b>(<i>this</i> <i title="&#xA; The type of parameter.&#xA; ">T</i>)<nobr> : <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a></nobr><blockquote>
Determines whether the specified object is <tt>null</tt>.
</blockquote></td>
</tr>
@@ -485,7 +485,7 @@
<b>
<a href="#M:WebSocketSharp.Ext.IsNullOrEmpty(System.String)">IsNullOrEmpty</a>
</b>(<i>this</i> <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>)<nobr> : <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a></nobr><blockquote>
Determines whether the specified <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> is <tt>null</tt> or <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>.
Determines whether the specified <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> is <tt>null</tt> or empty.
</blockquote></td>
</tr>
<tr valign="top">
@@ -1443,7 +1443,7 @@
<h3 id="M:WebSocketSharp.Ext.IsEmpty(System.String)">IsEmpty Method</h3>
<blockquote id="M:WebSocketSharp.Ext.IsEmpty(System.String):member">
<p class="Summary">
Determines whether the specified <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> is a <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>.
Determines whether the specified <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> is empty.
</p>
<h2>Syntax</h2>
<div class="Signature">public static <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a> <b>IsEmpty</b> (<i>this</i> <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> value)</div>
@@ -1460,7 +1460,7 @@
</blockquote>
<h4 class="Subsection">Returns</h4>
<blockquote class="SubsectionBox" id="M:WebSocketSharp.Ext.IsEmpty(System.String):Returns">
<tt>true</tt> if <i>value</i> is <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>; otherwise, <tt>false</tt>.
<tt>true</tt> if <i>value</i> is empty; otherwise, <tt>false</tt>.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="M:WebSocketSharp.Ext.IsEmpty(System.String):Remarks">
@@ -1593,7 +1593,7 @@
Determines whether the specified object is <tt>null</tt>.
</p>
<h2>Syntax</h2>
<div class="Signature">public static <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a> <b>IsNull&lt;T&gt;</b> (<i>this</i> <i title="&#xA; The type of the parameter.&#xA; ">T</i> obj)<br /> where T : class</div>
<div class="Signature">public static <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a> <b>IsNull&lt;T&gt;</b> (<i>this</i> <i title="&#xA; The type of parameter.&#xA; ">T</i> obj)<br /> where T : class</div>
<h4 class="Subsection">Type Parameters</h4>
<blockquote class="SubsectionBox" id="M:WebSocketSharp.Ext.IsNull``1(``0):Type Parameters">
<dl>
@@ -1601,7 +1601,7 @@
<i>T</i>
</dt>
<dd>
The type of the <i>obj</i> parameter.
The type of <i>obj</i> parameter.
</dd>
</dl>
</blockquote>
@@ -1612,13 +1612,13 @@
<i>obj</i>
</dt>
<dd>
A class to test.
An object to test.
</dd>
</dl>
</blockquote>
<h4 class="Subsection">Returns</h4>
<blockquote class="SubsectionBox" id="M:WebSocketSharp.Ext.IsNull``1(``0):Returns">
<tt>true</tt> if the <i>obj</i> parameter is <tt>null</tt>; otherwise, <tt>false</tt>.
<tt>true</tt> if <i>obj</i> is <tt>null</tt>; otherwise, <tt>false</tt>.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="M:WebSocketSharp.Ext.IsNull``1(``0):Remarks">
@@ -1681,7 +1681,7 @@
<h3 id="M:WebSocketSharp.Ext.IsNullOrEmpty(System.String)">IsNullOrEmpty Method</h3>
<blockquote id="M:WebSocketSharp.Ext.IsNullOrEmpty(System.String):member">
<p class="Summary">
Determines whether the specified <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> is <tt>null</tt> or <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>.
Determines whether the specified <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> is <tt>null</tt> or empty.
</p>
<h2>Syntax</h2>
<div class="Signature">public static <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a> <b>IsNullOrEmpty</b> (<i>this</i> <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> value)</div>
@@ -1698,7 +1698,7 @@
</blockquote>
<h4 class="Subsection">Returns</h4>
<blockquote class="SubsectionBox" id="M:WebSocketSharp.Ext.IsNullOrEmpty(System.String):Returns">
<tt>true</tt> if the <i>value</i> parameter is <tt>null</tt> or <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>; otherwise, <tt>false</tt>.
<tt>true</tt> if the <i>value</i> parameter is <tt>null</tt> or empty; otherwise, <tt>false</tt>.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="M:WebSocketSharp.Ext.IsNullOrEmpty(System.String):Remarks">

View File

@@ -211,7 +211,7 @@
</p>
<div id="T:WebSocketSharp.Opcode:Signature">
<h2>Syntax</h2>
<div class="Signature">[System.Flags]<br />public enum <b>Opcode</b></div>
<div class="Signature">public enum <b>Opcode</b></div>
</div>
<div class="Remarks" id="T:WebSocketSharp.Opcode:Docs">
<h2 class="Section">Remarks</h2>

View File

@@ -270,6 +270,23 @@
<div class="SectionBox" id="Public Properties">
<div class="SubsectionBox">
<table class="TypeMembers">
<tr valign="top">
<td>
<div>
</div>
</td>
<td>
<b>
<a href="#P:WebSocketSharp.WebSocket.Compression">Compression</a>
</b>
</td>
<td>
<i>
<a href="../WebSocketSharp/CompressionMethod.html">CompressionMethod</a>
</i>.
Gets or sets the compression method used to compress the payload data of the WebSocket Data frame.
</td>
</tr>
<tr valign="top">
<td>[read-only]<div></div></td>
<td>
@@ -295,7 +312,7 @@
<i>
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>
</i>.
Gets the extensions selected by the server.
Gets the WebSocket extensions selected by the server.
</td>
</tr>
<tr valign="top">
@@ -309,7 +326,7 @@
<i>
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a>
</i>.
Gets a value indicating whether a connection is alive.
Gets a value indicating whether the WebSocket connection is alive.
</td>
</tr>
<tr valign="top">
@@ -323,7 +340,7 @@
<i>
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a>
</i>.
Gets a value indicating whether a connection is secure.
Gets a value indicating whether the WebSocket connection is secure.
</td>
</tr>
<tr valign="top">
@@ -354,7 +371,7 @@
<i>
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>
</i>.
Gets the subprotocol selected by the server.
Gets the WebSocket subprotocol selected by the server.
</td>
</tr>
<tr valign="top">
@@ -368,7 +385,7 @@
<i>
<a href="../WebSocketSharp/WsState.html">WsState</a>
</i>.
Gets the state of the connection.
Gets the state of the WebSocket connection.
</td>
</tr>
<tr valign="top">
@@ -382,7 +399,7 @@
<i>
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Uri">Uri</a>
</i>.
Gets the WebSocket URL.
Gets the WebSocket URL to connect.
</td>
</tr>
</table>
@@ -439,8 +456,8 @@
<b>
<a href="#M:WebSocketSharp.WebSocket.Close(System.UInt16,System.String)">Close</a>
</b>(<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.UInt16">ushort</a>, <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>)<blockquote>
Closes the WebSocket connection with the specified <i>code</i> and <i>reason</i>, and
releases all associated resources.
Closes the WebSocket connection with the specified <i>code</i> and
<i>reason</i>, and releases all associated resources.
</blockquote></td>
</tr>
<tr valign="top">
@@ -452,8 +469,8 @@
<b>
<a href="#M:WebSocketSharp.WebSocket.Close(WebSocketSharp.CloseStatusCode,System.String)">Close</a>
</b>(<a href="../WebSocketSharp/CloseStatusCode.html">CloseStatusCode</a>, <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>)<blockquote>
Closes the WebSocket connection with the specified <i>code</i> and <i>reason</i>, and
releases all associated resources.
Closes the WebSocket connection with the specified <i>code</i> and
<i>reason</i>, and releases all associated resources.
</blockquote></td>
</tr>
<tr valign="top">
@@ -665,7 +682,7 @@
<td colspan="2">
<b>
<a href="../WebSocketSharp/Ext.html#M:WebSocketSharp.Ext.IsNull``1(``0)">IsNull&lt;T&gt;</a>
</b>(<i>this</i> <i title="&#xA; The type of the parameter.&#xA; ">T</i>)<nobr> : <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a></nobr><blockquote>
</b>(<i>this</i> <i title="&#xA; The type of parameter.&#xA; ">T</i>)<nobr> : <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a></nobr><blockquote>
Determines whether the specified object is <tt>null</tt>.
</blockquote></td>
</tr>
@@ -867,8 +884,8 @@
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="M:WebSocketSharp.WebSocket.Close(System.UInt16):Remarks">
Emits a <a href="../WebSocketSharp/WebSocket.html#E:WebSocketSharp.WebSocket.OnError">WebSocket.OnError</a> event if <i>code</i> is not in the allowable range of
the WebSocket close status code, and do nothing any more.
This Close method emits a <a href="../WebSocketSharp/WebSocket.html#E:WebSocketSharp.WebSocket.OnError">WebSocket.OnError</a> event if <i>code</i> is not
in the allowable range of the WebSocket close status code.
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="M:WebSocketSharp.WebSocket.Close(System.UInt16):Version Information">
@@ -906,8 +923,8 @@
<h3 id="M:WebSocketSharp.WebSocket.Close(System.UInt16,System.String)">Close Method</h3>
<blockquote id="M:WebSocketSharp.WebSocket.Close(System.UInt16,System.String):member">
<p class="Summary">
Closes the WebSocket connection with the specified <i>code</i> and <i>reason</i>, and
releases all associated resources.
Closes the WebSocket connection with the specified <i>code</i> and
<i>reason</i>, and releases all associated resources.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void">void</a> <b>Close</b> (<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.UInt16">ushort</a> code, <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> reason)</div>
@@ -930,8 +947,8 @@
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="M:WebSocketSharp.WebSocket.Close(System.UInt16,System.String):Remarks">
Emits a <a href="../WebSocketSharp/WebSocket.html#E:WebSocketSharp.WebSocket.OnError">WebSocket.OnError</a> event if <i>code</i> is not in the allowable range of
the WebSocket close status code, and do nothing any more.
This Close method emits a <a href="../WebSocketSharp/WebSocket.html#E:WebSocketSharp.WebSocket.OnError">WebSocket.OnError</a> event if <i>code</i> is not
in the allowable range of the WebSocket close status code.
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="M:WebSocketSharp.WebSocket.Close(System.UInt16,System.String):Version Information">
@@ -941,8 +958,8 @@
<h3 id="M:WebSocketSharp.WebSocket.Close(WebSocketSharp.CloseStatusCode,System.String)">Close Method</h3>
<blockquote id="M:WebSocketSharp.WebSocket.Close(WebSocketSharp.CloseStatusCode,System.String):member">
<p class="Summary">
Closes the WebSocket connection with the specified <i>code</i> and <i>reason</i>, and
releases all associated resources.
Closes the WebSocket connection with the specified <i>code</i> and
<i>reason</i>, and releases all associated resources.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void">void</a> <b>Close</b> (<a href="../WebSocketSharp/CloseStatusCode.html">CloseStatusCode</a> code, <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> reason)</div>
@@ -972,6 +989,27 @@
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" />
</blockquote>
<h3 id="P:WebSocketSharp.WebSocket.Compression">Compression Property</h3>
<blockquote id="P:WebSocketSharp.WebSocket.Compression:member">
<p class="Summary">
Gets or sets the compression method used to compress the payload data of the WebSocket Data frame.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="../WebSocketSharp/CompressionMethod.html">CompressionMethod</a> <b>Compression</b> { get; set; }</div>
<h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WebSocket.Compression:Value">
One of the <a href="../WebSocketSharp/CompressionMethod.html">WebSocketSharp.CompressionMethod</a> values that indicates the compression method to use.
The default is <a href="../WebSocketSharp/CompressionMethod.html#F:WebSocketSharp.CompressionMethod.NONE">CompressionMethod.NONE</a>.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.WebSocket.Compression:Remarks">
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="P:WebSocketSharp.WebSocket.Compression:Version Information">
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" />
</blockquote>
<h3 id="M:WebSocketSharp.WebSocket.Connect">Connect Method</h3>
<blockquote id="M:WebSocketSharp.WebSocket.Connect:member">
<p class="Summary">
@@ -1028,14 +1066,13 @@
<h3 id="P:WebSocketSharp.WebSocket.Extensions">Extensions Property</h3>
<blockquote id="P:WebSocketSharp.WebSocket.Extensions:member">
<p class="Summary">
Gets the extensions selected by the server.
Gets the WebSocket extensions selected by the server.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> <b>Extensions</b> { get; }</div>
<h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WebSocket.Extensions:Value">
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains the extensions if any. The default is <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>.
(Currently this will only ever be the <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>.)
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.WebSocket.Extensions:Remarks">
@@ -1049,7 +1086,7 @@
<h3 id="P:WebSocketSharp.WebSocket.IsAlive">IsAlive Property</h3>
<blockquote id="P:WebSocketSharp.WebSocket.IsAlive:member">
<p class="Summary">
Gets a value indicating whether a connection is alive.
Gets a value indicating whether the WebSocket connection is alive.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a> <b>IsAlive</b> { get; }</div>
@@ -1069,7 +1106,7 @@
<h3 id="P:WebSocketSharp.WebSocket.IsSecure">IsSecure Property</h3>
<blockquote id="P:WebSocketSharp.WebSocket.IsSecure:member">
<p class="Summary">
Gets a value indicating whether a connection is secure.
Gets a value indicating whether the WebSocket connection is secure.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a> <b>IsSecure</b> { get; }</div>
@@ -1230,13 +1267,13 @@
<h3 id="P:WebSocketSharp.WebSocket.Protocol">Protocol Property</h3>
<blockquote id="P:WebSocketSharp.WebSocket.Protocol:member">
<p class="Summary">
Gets the subprotocol selected by the server.
Gets the WebSocket subprotocol selected by the server.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> <b>Protocol</b> { get; }</div>
<h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WebSocket.Protocol:Value">
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains the subprotocol if any. By default, <tt>String.Empty</tt>.
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains the subprotocol if any. The default is <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.WebSocket.Protocol:Remarks">
@@ -1250,13 +1287,13 @@
<h3 id="P:WebSocketSharp.WebSocket.ReadyState">ReadyState Property</h3>
<blockquote id="P:WebSocketSharp.WebSocket.ReadyState:member">
<p class="Summary">
Gets the state of the connection.
Gets the state of the WebSocket connection.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="../WebSocketSharp/WsState.html">WsState</a> <b>ReadyState</b> { get; }</div>
<h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WebSocket.ReadyState:Value">
One of the <a href="../WebSocketSharp/WsState.html">WebSocketSharp.WsState</a>. By default, <tt>WsState.CONNECTING</tt>.
One of the <a href="../WebSocketSharp/WsState.html">WebSocketSharp.WsState</a> values. The default is <a href="../WebSocketSharp/WsState.html#F:WebSocketSharp.WsState.CONNECTING">WsState.CONNECTING</a>.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.WebSocket.ReadyState:Remarks">
@@ -1480,13 +1517,13 @@
<h3 id="P:WebSocketSharp.WebSocket.Url">Url Property</h3>
<blockquote id="P:WebSocketSharp.WebSocket.Url:member">
<p class="Summary">
Gets the WebSocket URL.
Gets the WebSocket URL to connect.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Uri">Uri</a> <b>Url</b> { get; }</div>
<h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WebSocket.Url:Value">
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Uri">Uri</a> that contains the WebSocket URL.
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Uri">Uri</a> that contains the WebSocket URL to connect.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.WebSocket.Url:Remarks">

View File

@@ -226,6 +226,14 @@
Contains the values of the status codes for the WebSocket connection closure.
</td>
</tr>
<tr valign="top">
<td>
<a href="./CompressionMethod.html">CompressionMethod</a>
</td>
<td>
Contains the values of the compression methods used to compress the payload data of the WebSocket Data frame.
</td>
</tr>
<tr valign="top">
<td>
<a href="./ErrorEventArgs.html">ErrorEventArgs</a>

View File

@@ -228,6 +228,14 @@
Contains the values of the status codes for the WebSocket connection closure.
</td>
</tr>
<tr valign="top">
<td>
<a href="WebSocketSharp/CompressionMethod.html">CompressionMethod</a>
</td>
<td>
Contains the values of the compression methods used to compress the payload data of the WebSocket Data frame.
</td>
</tr>
<tr valign="top">
<td>
<a href="WebSocketSharp/ErrorEventArgs.html">ErrorEventArgs</a>

View File

@@ -0,0 +1,48 @@
<Type Name="CompressionMethod" FullName="WebSocketSharp.CompressionMethod">
<TypeSignature Language="C#" Value="public enum CompressionMethod" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed CompressionMethod extends System.Enum" />
<AssemblyInfo>
<AssemblyName>websocket-sharp</AssemblyName>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Enum</BaseTypeName>
</Base>
<Docs>
<summary>
Contains the values of the compression methods used to compress the payload data of the WebSocket Data frame.
</summary>
<remarks>
The <b>CompressionMethod</b> enumeration contains the values of the compression methods defined in
<see href="http://tools.ietf.org/html/draft-tyoshino-hybi-permessage-compression-00">WebSocket Per-message Compression</see>
specification for a WebSocket extension.
</remarks>
</Docs>
<Members>
<Member MemberName="DEFLATE">
<MemberSignature Language="C#" Value="DEFLATE" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype WebSocketSharp.CompressionMethod DEFLATE = unsigned int8(1)" />
<MemberType>Field</MemberType>
<ReturnValue>
<ReturnType>WebSocketSharp.CompressionMethod</ReturnType>
</ReturnValue>
<Docs>
<summary>
Indicates using DEFLATE.
</summary>
</Docs>
</Member>
<Member MemberName="NONE">
<MemberSignature Language="C#" Value="NONE" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype WebSocketSharp.CompressionMethod NONE = unsigned int8(0)" />
<MemberType>Field</MemberType>
<ReturnValue>
<ReturnType>WebSocketSharp.CompressionMethod</ReturnType>
</ReturnValue>
<Docs>
<summary>
Indicates non compression.
</summary>
</Docs>
</Member>
</Members>
</Type>

View File

@@ -492,10 +492,10 @@
A <see cref="T:System.String" /> to test.
</param>
<summary>
Determines whether the specified <see cref="T:System.String" /> is a <see cref="F:System.String.Empty" />.
Determines whether the specified <see cref="T:System.String" /> is empty.
</summary>
<returns>
<c>true</c> if <paramref name="value" /> is <see cref="F:System.String.Empty" />; otherwise, <c>false</c>.
<c>true</c> if <paramref name="value" /> is empty; otherwise, <c>false</c>.
</returns>
<remarks>To be added.</remarks>
</Docs>
@@ -595,16 +595,16 @@
</Parameters>
<Docs>
<typeparam name="T">
The type of the <paramref name="obj" /> parameter.
The type of <paramref name="obj" /> parameter.
</typeparam>
<param name="obj">
A <b>class</b> to test.
An <b>object</b> to test.
</param>
<summary>
Determines whether the specified object is <see langword="null" />.
</summary>
<returns>
<c>true</c> if the <paramref name="obj" /> parameter is <see langword="null" />; otherwise, <c>false</c>.
<c>true</c> if <paramref name="obj" /> is <see langword="null" />; otherwise, <c>false</c>.
</returns>
<remarks>To be added.</remarks>
</Docs>
@@ -662,10 +662,10 @@
A <see cref="T:System.String" /> to test.
</param>
<summary>
Determines whether the specified <see cref="T:System.String" /> is <see langword="null" /> or <see cref="F:System.String.Empty" />.
Determines whether the specified <see cref="T:System.String" /> is <see langword="null" /> or empty.
</summary>
<returns>
<c>true</c> if the <paramref name="value" /> parameter is <see langword="null" /> or <see cref="F:System.String.Empty" />; otherwise, <c>false</c>.
<c>true</c> if the <paramref name="value" /> parameter is <see langword="null" /> or empty; otherwise, <c>false</c>.
</returns>
<remarks>To be added.</remarks>
</Docs>

View File

@@ -7,11 +7,6 @@
<Base>
<BaseTypeName>System.Enum</BaseTypeName>
</Base>
<Attributes>
<Attribute>
<AttributeName>System.Flags</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>
Contains the values of the opcodes that denotes the frame type of the WebSocket frame.

View File

@@ -1,6 +1,6 @@
<Type Name="WebSocket" FullName="WebSocketSharp.WebSocket">
<TypeSignature Language="C#" Value="public class WebSocket : IDisposable" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit WebSocket extends System.Object implements class System.IDisposable" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi WebSocket extends System.Object implements class System.IDisposable" />
<AssemblyInfo>
<AssemblyName>websocket-sharp</AssemblyName>
</AssemblyInfo>
@@ -142,8 +142,8 @@
releases all associated resources.
</summary>
<remarks>
Emits a <see cref="E:WebSocketSharp.WebSocket.OnError" /> event if <paramref name="code" /> is not in the allowable range of
the WebSocket close status code, and do nothing any more.
This Close method emits a <see cref="E:WebSocketSharp.WebSocket.OnError" /> event if <paramref name="code" /> is not
in the allowable range of the WebSocket close status code.
</remarks>
</Docs>
</Member>
@@ -187,12 +187,12 @@
A <see cref="T:System.String" /> that contains the reason for closure.
</param>
<summary>
Closes the WebSocket connection with the specified <paramref name="code" /> and <paramref name="reason" />, and
releases all associated resources.
Closes the WebSocket connection with the specified <paramref name="code" /> and
<paramref name="reason" />, and releases all associated resources.
</summary>
<remarks>
Emits a <see cref="E:WebSocketSharp.WebSocket.OnError" /> event if <paramref name="code" /> is not in the allowable range of
the WebSocket close status code, and do nothing any more.
This Close method emits a <see cref="E:WebSocketSharp.WebSocket.OnError" /> event if <paramref name="code" /> is not
in the allowable range of the WebSocket close status code.
</remarks>
</Docs>
</Member>
@@ -215,12 +215,30 @@
A <see cref="T:System.String" /> that contains the reason for closure.
</param>
<summary>
Closes the WebSocket connection with the specified <paramref name="code" /> and <paramref name="reason" />, and
releases all associated resources.
Closes the WebSocket connection with the specified <paramref name="code" /> and
<paramref name="reason" />, and releases all associated resources.
</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Compression">
<MemberSignature Language="C#" Value="public WebSocketSharp.CompressionMethod Compression { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype WebSocketSharp.CompressionMethod Compression" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>WebSocketSharp.CompressionMethod</ReturnType>
</ReturnValue>
<Docs>
<summary>
Gets or sets the compression method used to compress the payload data of the WebSocket Data frame.
</summary>
<value>
One of the <see cref="T:WebSocketSharp.CompressionMethod" /> values that indicates the compression method to use.
The default is <see cref="F:WebSocketSharp.CompressionMethod.NONE" />.
</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Connect">
<MemberSignature Language="C#" Value="public void Connect ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Connect() cil managed" />
@@ -280,11 +298,10 @@
</ReturnValue>
<Docs>
<summary>
Gets the extensions selected by the server.
Gets the WebSocket extensions selected by the server.
</summary>
<value>
A <see cref="T:System.String" /> that contains the extensions if any. The default is <see cref="F:System.String.Empty" />.
(Currently this will only ever be the <see cref="F:System.String.Empty" />.)
</value>
<remarks>To be added.</remarks>
</Docs>
@@ -298,7 +315,7 @@
</ReturnValue>
<Docs>
<summary>
Gets a value indicating whether a connection is alive.
Gets a value indicating whether the WebSocket connection is alive.
</summary>
<value>
<c>true</c> if the connection is alive; otherwise, <c>false</c>.
@@ -315,7 +332,7 @@
</ReturnValue>
<Docs>
<summary>
Gets a value indicating whether a connection is secure.
Gets a value indicating whether the WebSocket connection is secure.
</summary>
<value>
<c>true</c> if the connection is secure; otherwise, <c>false</c>.
@@ -454,10 +471,10 @@
</ReturnValue>
<Docs>
<summary>
Gets the subprotocol selected by the server.
Gets the WebSocket subprotocol selected by the server.
</summary>
<value>
A <see cref="T:System.String" /> that contains the subprotocol if any. By default, <c>String.Empty</c>.
A <see cref="T:System.String" /> that contains the subprotocol if any. The default is <see cref="F:System.String.Empty" />.
</value>
<remarks>To be added.</remarks>
</Docs>
@@ -471,10 +488,10 @@
</ReturnValue>
<Docs>
<summary>
Gets the state of the connection.
Gets the state of the WebSocket connection.
</summary>
<value>
One of the <see cref="T:WebSocketSharp.WsState" />. By default, <c>WsState.CONNECTING</c>.
One of the <see cref="T:WebSocketSharp.WsState" /> values. The default is <see cref="F:WebSocketSharp.WsState.CONNECTING" />.
</value>
<remarks>To be added.</remarks>
</Docs>
@@ -643,10 +660,10 @@
</ReturnValue>
<Docs>
<summary>
Gets the WebSocket URL.
Gets the WebSocket URL to connect.
</summary>
<value>
A <see cref="T:System.Uri" /> that contains the WebSocket URL.
A <see cref="T:System.Uri" /> that contains the WebSocket URL to connect.
</value>
<remarks>To be added.</remarks>
</Docs>

View File

@@ -1,6 +1,6 @@
<Overview>
<Assemblies>
<Assembly Name="websocket-sharp" Version="1.0.2.42633">
<Assembly Name="websocket-sharp" Version="1.0.2.32570">
<AssemblyPublicKey>[00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 11 00 00 00 29 17 fb 89 fe c3 91 f7 2b cb 8b e2 61 d2 3f 05 93 6d 65 a8 9e 63 72 a6 f5 d5 2c f2 9d 20 fa 0b c0 70 6a f6 88 7e 8b 90 3f 39 f5 76 c8 48 e0 bb 7b b2 7b ed d3 10 a7 1a 0f 70 98 0f 7f f4 4b 53 09 d2 a5 ef 36 c3 56 b4 aa f0 91 72 63 25 07 89 e0 93 3e 3f 2e f2 b9 73 0e 12 15 5d 43 56 c3 f4 70 a5 89 fe f7 f6 ac 3e 77 c2 d8 d0 84 91 f4 0c d1 f3 8e dc c3 c3 b8 38 3d 0c bf 17 de 20 78 c1 ]</AssemblyPublicKey>
<Attributes>
<Attribute>
@@ -37,6 +37,7 @@
<Type Name="ByteOrder" Kind="Enumeration" />
<Type Name="CloseEventArgs" Kind="Class" />
<Type Name="CloseStatusCode" Kind="Enumeration" />
<Type Name="CompressionMethod" Kind="Enumeration" />
<Type Name="ErrorEventArgs" Kind="Class" />
<Type Name="Ext" Kind="Class" />
<Type Name="MessageEventArgs" Kind="Class" />
@@ -586,7 +587,7 @@
A <see cref="T:System.String" /> to test.
</param>
<summary>
Determines whether the specified <see cref="T:System.String" /> is a <see cref="F:System.String.Empty" />.
Determines whether the specified <see cref="T:System.String" /> is empty.
</summary>
</Docs>
<Link Type="WebSocketSharp.Ext" Member="M:WebSocketSharp.Ext.IsEmpty(System.String)" />
@@ -694,10 +695,10 @@
</Parameters>
<Docs>
<typeparam name="T">
The type of the <paramref name="obj" /> parameter.
The type of <paramref name="obj" /> parameter.
</typeparam>
<param name="obj">
A <b>class</b> to test.
An <b>object</b> to test.
</param>
<summary>
Determines whether the specified object is <see langword="null" />.
@@ -765,7 +766,7 @@
A <see cref="T:System.String" /> to test.
</param>
<summary>
Determines whether the specified <see cref="T:System.String" /> is <see langword="null" /> or <see cref="F:System.String.Empty" />.
Determines whether the specified <see cref="T:System.String" /> is <see langword="null" /> or empty.
</summary>
</Docs>
<Link Type="WebSocketSharp.Ext" Member="M:WebSocketSharp.Ext.IsNullOrEmpty(System.String)" />

View File

@@ -122,6 +122,7 @@
<Compile Include="Server\HttpRequestEventArgs.cs" />
<Compile Include="Net\HttpHeaderType.cs" />
<Compile Include="Net\HttpHeaderInfo.cs" />
<Compile Include="CompressionMethod.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

Binary file not shown.