Removed WsReceivedTooBigMessageException.cs. Added WebSocketException.cs

This commit is contained in:
sta 2013-05-01 16:53:06 +09:00
parent 585686f401
commit e0846e1d84
32 changed files with 421 additions and 28 deletions

Binary file not shown.

View File

@ -215,6 +215,19 @@ namespace WebSocketSharp {
: null; : null;
} }
internal static string GetMessage(this CloseStatusCode code)
{
if (code == CloseStatusCode.ABNORMAL)
return "What we've got here is a failure to communicate in the WebSocket protocol.";
if (code == CloseStatusCode.TOO_BIG)
return String.Format(
"The size of received payload data is bigger than the allowable value ({0} bytes).",
PayloadData.MaxLength);
return String.Empty;
}
internal static string GetValueInternal(this string nameAndValue, string separator) internal static string GetValueInternal(this string nameAndValue, string separator)
{ {
int i = nameAndValue.IndexOf(separator); int i = nameAndValue.IndexOf(separator);

View File

@ -903,8 +903,8 @@ namespace WebSocketSharp {
#if DEBUG #if DEBUG
Console.WriteLine("WS: Info@processAbnormal: Start closing handshake."); Console.WriteLine("WS: Info@processAbnormal: Start closing handshake.");
#endif #endif
var msg = "What we've got here is a failure to communicate in the WebSocket protocol."; var code = CloseStatusCode.ABNORMAL;
Close(CloseStatusCode.ABNORMAL, msg); Close(code, code.GetMessage());
return true; return true;
} }
@ -1368,9 +1368,9 @@ namespace WebSocketSharp {
else else
_exitReceiving.Set(); _exitReceiving.Set();
} }
catch (WsReceivedTooBigMessageException ex) catch (WebSocketException ex)
{ {
Close(CloseStatusCode.TOO_BIG, ex.Message); Close(ex.Code, ex.Message);
} }
catch (Exception) catch (Exception)
{ {

View File

@ -1,6 +1,6 @@
#region MIT License #region License
/* /*
* WsReceivedTooBigMessageException.cs * WebSocketException.cs
* *
* The MIT License * The MIT License
* *
@ -30,24 +30,43 @@ using System;
namespace WebSocketSharp { namespace WebSocketSharp {
public class WsReceivedTooBigMessageException : Exception /// <summary>
/// Represents the exception that occurred when attempting to perform an operation on the WebSocket connection.
/// </summary>
public class WebSocketException : Exception
{ {
private static readonly string _defaultMessage; #region Internal Constructors
static WsReceivedTooBigMessageException() internal WebSocketException()
{ : this(CloseStatusCode.ABNORMAL)
_defaultMessage = String.Format(
"Size of received payload data is bigger than the allowable value({0} bytes).", PayloadData.MaxLength);
}
public WsReceivedTooBigMessageException()
: this(_defaultMessage)
{ {
} }
public WsReceivedTooBigMessageException(string message) internal WebSocketException(CloseStatusCode code)
: base(message) : this(code, code.GetMessage())
{ {
} }
internal WebSocketException(CloseStatusCode code, string message)
: base(message)
{
Code = code;
}
#endregion
#region Public Properties
/// <summary>
/// Gets the <see cref="CloseStatusCode"/> associated with a <see cref="WebSocketException"/>.
/// </summary>
/// <value>
/// One of the <see cref="CloseStatusCode"/> values that indicates the cause of the exception.
/// </value>
public CloseStatusCode Code {
get; internal set;
}
#endregion
} }
} }

View File

@ -485,7 +485,7 @@ namespace WebSocketSharp {
} }
if (frame.PayloadLen > 126 && length > PayloadData.MaxLength) if (frame.PayloadLen > 126 && length > PayloadData.MaxLength)
throw new WsReceivedTooBigMessageException(); throw new WebSocketException(CloseStatusCode.TOO_BIG);
var buffer = length <= (ulong)_readBufferLen var buffer = length <= (ulong)_readBufferLen
? stream.ReadBytes((int)length) ? stream.ReadBytes((int)length)

View File

@ -830,6 +830,19 @@
<c>true</c> if the WebSocket connection closed cleanly; otherwise, <c>false</c>. <c>true</c> if the WebSocket connection closed cleanly; otherwise, <c>false</c>.
</value> </value>
</member> </member>
<member name="T:WebSocketSharp.WebSocketException">
<summary>
Represents the exception that occurred when attempting to perform an operation on the WebSocket connection.
</summary>
</member>
<member name="P:WebSocketSharp.WebSocketException.Code">
<summary>
Gets the <see cref="T:WebSocketSharp.CloseStatusCode" /> associated with a <see cref="T:WebSocketSharp.WebSocketException" />.
</summary>
<value>
One of the <see cref="T:WebSocketSharp.CloseStatusCode" /> values that indicates the cause of the exception.
</value>
</member>
<member name="T:WebSocketSharp.ByteOrder"> <member name="T:WebSocketSharp.ByteOrder">
<summary> <summary>
Contains the values that indicate whether the byte order is a Little-endian or Big-endian. Contains the values that indicate whether the byte order is a Little-endian or Big-endian.

View File

@ -0,0 +1,312 @@
<html>
<head>
<title>WebSocketSharp.WebSocketException</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.WebSocketException">Overview</a>
</p>
<p>
<a href="#T:WebSocketSharp.WebSocketException:Signature">Signature</a>
</p>
<p>
<a href="#T:WebSocketSharp.WebSocketException:Docs">Remarks</a>
</p>
<p>
<a href="#Members">Members</a>
</p>
<p>
<a href="#T:WebSocketSharp.WebSocketException:Members">Member Details</a>
</p>
</div>
<h1 class="PageTitle" id="T:WebSocketSharp.WebSocketException">WebSocketException Class</h1>
<p class="Summary" id="T:WebSocketSharp.WebSocketException:Summary">
Represents the exception that occurred when attempting to perform an operation on the WebSocket connection.
</p>
<div id="T:WebSocketSharp.WebSocketException:Signature">
<h2>Syntax</h2>
<div class="Signature">public class <b>WebSocketException</b> : <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Exception">Exception</a></div>
</div>
<div class="Remarks" id="T:WebSocketSharp.WebSocketException:Docs">
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="T:WebSocketSharp.WebSocketException:Docs:Remarks">
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="T:WebSocketSharp.WebSocketException:Docs:Version Information">
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<h2 class="Section" id="Members">Members</h2>
<div class="SectionBox" id="_Members">
<p>
See Also: Inherited members from
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Exception">Exception</a>.
</p>
<h2 class="Section">Public Properties</h2>
<div class="SectionBox" id="Public Properties">
<div class="SubsectionBox">
<table class="TypeMembers">
<tr valign="top">
<td>[read-only]<div></div></td>
<td>
<b>
<a href="#P:WebSocketSharp.WebSocketException.Code">Code</a>
</b>
</td>
<td>
<i>
<a href="../WebSocketSharp/CloseStatusCode.html">CloseStatusCode</a>
</i>.
Gets the <a href="../WebSocketSharp/CloseStatusCode.html">WebSocketSharp.CloseStatusCode</a> associated with a <a href="../WebSocketSharp/WebSocketException.html">WebSocketSharp.WebSocketException</a>.
</td>
</tr>
</table>
</div>
</div>
<h2 class="Section">Extension Methods</h2>
<div class="SectionBox" id="Extension Methods">
<div class="SubsectionBox">
<table class="TypeMembers">
<tr valign="top">
<td>
<div>static </div>
</td>
<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 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>
<tr valign="top">
<td>
<div>static </div>
</td>
<td colspan="2">
<b>
<a href="../WebSocketSharp/Ext.html#M:WebSocketSharp.Ext.IsNullDo``1(``0,System.Action)">IsNullDo&lt;T&gt;</a>
</b>(<i>this</i> <i title="&#xA; The type of the parameter.&#xA; ">T</i>, <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Action">Action</a>)<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>.
And invokes the specified <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Action">Action</a> delegate if the specified object is <tt>null</tt>.
</blockquote></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="Members" id="T:WebSocketSharp.WebSocketException:Members">
<h2 class="Section" id="MemberDetails">Member Details</h2>
<div class="SectionBox" id="_MemberDetails">
<h3 id="P:WebSocketSharp.WebSocketException.Code">Code Property</h3>
<blockquote id="P:WebSocketSharp.WebSocketException.Code:member">
<p class="Summary">
Gets the <a href="../WebSocketSharp/CloseStatusCode.html">WebSocketSharp.CloseStatusCode</a> associated with a <a href="../WebSocketSharp/WebSocketException.html">WebSocketSharp.WebSocketException</a>.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="../WebSocketSharp/CloseStatusCode.html">CloseStatusCode</a> <b>Code</b> { get; }</div>
<h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WebSocketException.Code:Value">
One of the <a href="../WebSocketSharp/CloseStatusCode.html">WebSocketSharp.CloseStatusCode</a> values that indicates the cause of the exception.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.WebSocketException.Code: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.WebSocketException.Code:Version Information">
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" />
</blockquote>
</div>
</div>
<hr size="1" />
<div class="Copyright">
</div>
</body>
</html>

View File

@ -276,11 +276,11 @@
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td> <td>
<a href="./WsReceivedTooBigMessageException.html">WsReceivedTooBigMessageException</a> <a href="./WebSocketException.html">WebSocketException</a>
</td> </td>
<td> <td>
<span class="NotEntered">Documentation for this section has not yet been entered.</span> Represents the exception that occurred when attempting to perform an operation on the WebSocket connection.
</td> </td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td> <td>

View File

@ -278,11 +278,11 @@
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td> <td>
<a href="WebSocketSharp/WsReceivedTooBigMessageException.html">WsReceivedTooBigMessageException</a> <a href="WebSocketSharp/WebSocketException.html">WebSocketException</a>
</td> </td>
<td> <td>
<span class="NotEntered">Documentation for this section has not yet been entered.</span> Represents the exception that occurred when attempting to perform an operation on the WebSocket connection.
</td> </td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td> <td>

View File

@ -0,0 +1,36 @@
<Type Name="WebSocketException" FullName="WebSocketSharp.WebSocketException">
<TypeSignature Language="C#" Value="public class WebSocketException : Exception" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit WebSocketException extends System.Exception" />
<AssemblyInfo>
<AssemblyName>websocket-sharp</AssemblyName>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Exception</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>
Represents the exception that occurred when attempting to perform an operation on the WebSocket connection.
</summary>
<remarks>To be added.</remarks>
</Docs>
<Members>
<Member MemberName="Code">
<MemberSignature Language="C#" Value="public WebSocketSharp.CloseStatusCode Code { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype WebSocketSharp.CloseStatusCode Code" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>WebSocketSharp.CloseStatusCode</ReturnType>
</ReturnValue>
<Docs>
<summary>
Gets the <see cref="T:WebSocketSharp.CloseStatusCode" /> associated with a <see cref="T:WebSocketSharp.WebSocketException" />.
</summary>
<value>
One of the <see cref="T:WebSocketSharp.CloseStatusCode" /> values that indicates the cause of the exception.
</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>

View File

@ -1,6 +1,6 @@
<Overview> <Overview>
<Assemblies> <Assemblies>
<Assembly Name="websocket-sharp" Version="1.0.2.30839"> <Assembly Name="websocket-sharp" Version="1.0.2.28778">
<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> <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> <Attributes>
<Attribute> <Attribute>
@ -43,7 +43,7 @@
<Type Name="MessageEventArgs" Kind="Class" /> <Type Name="MessageEventArgs" Kind="Class" />
<Type Name="Opcode" Kind="Enumeration" /> <Type Name="Opcode" Kind="Enumeration" />
<Type Name="WebSocket" Kind="Class" /> <Type Name="WebSocket" Kind="Class" />
<Type Name="WsReceivedTooBigMessageException" Kind="Class" /> <Type Name="WebSocketException" Kind="Class" />
<Type Name="WsState" Kind="Enumeration" /> <Type Name="WsState" Kind="Enumeration" />
</Namespace> </Namespace>
<Namespace Name="WebSocketSharp.Net"> <Namespace Name="WebSocketSharp.Net">

View File

@ -67,7 +67,6 @@
<Compile Include="WsState.cs" /> <Compile Include="WsState.cs" />
<Compile Include="MessageEventArgs.cs" /> <Compile Include="MessageEventArgs.cs" />
<Compile Include="CloseEventArgs.cs" /> <Compile Include="CloseEventArgs.cs" />
<Compile Include="WsReceivedTooBigMessageException.cs" />
<Compile Include="ByteOrder.cs" /> <Compile Include="ByteOrder.cs" />
<Compile Include="ErrorEventArgs.cs" /> <Compile Include="ErrorEventArgs.cs" />
<Compile Include="WebSocket.cs" /> <Compile Include="WebSocket.cs" />
@ -123,6 +122,7 @@
<Compile Include="Net\HttpHeaderType.cs" /> <Compile Include="Net\HttpHeaderType.cs" />
<Compile Include="Net\HttpHeaderInfo.cs" /> <Compile Include="Net\HttpHeaderInfo.cs" />
<Compile Include="CompressionMethod.cs" /> <Compile Include="CompressionMethod.cs" />
<Compile Include="WebSocketException.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>

Binary file not shown.