Modified WebSocket.cs
This commit is contained in:
parent
2a892ff57f
commit
df1ff81483
Binary file not shown.
@ -111,6 +111,7 @@ namespace Example
|
||||
"notification-message-im");
|
||||
};
|
||||
|
||||
//ws.Origin = "http://echo.websocket.org";
|
||||
//ws.SetCookie(new Cookie("nobita", "\"idiot, gunfighter\""));
|
||||
//ws.SetCookie(new Cookie("dora", "tanuki"));
|
||||
ws.Connect();
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -50,7 +50,8 @@ namespace WebSocketSharp {
|
||||
/// Implements the WebSocket interface.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The WebSocket class provides methods and properties for two-way communication using the WebSocket protocol (RFC 6455).
|
||||
/// The WebSocket class provides a set of methods and properties for two-way communication
|
||||
/// using the WebSocket protocol (<see href="http://tools.ietf.org/html/rfc6455">RFC 6455</see>).
|
||||
/// </remarks>
|
||||
public class WebSocket : IDisposable
|
||||
{
|
||||
@ -73,6 +74,7 @@ namespace WebSocketSharp {
|
||||
private AutoResetEvent _exitReceiving;
|
||||
private Object _forClose;
|
||||
private Object _forSend;
|
||||
private string _origin;
|
||||
private string _protocol;
|
||||
private string _protocols;
|
||||
private volatile WsState _readyState;
|
||||
@ -92,6 +94,7 @@ namespace WebSocketSharp {
|
||||
_extensions = String.Empty;
|
||||
_forClose = new Object();
|
||||
_forSend = new Object();
|
||||
_origin = String.Empty;
|
||||
_protocol = String.Empty;
|
||||
_readyState = WsState.CONNECTING;
|
||||
}
|
||||
@ -123,11 +126,8 @@ namespace WebSocketSharp {
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WebSocket"/> class with the specified WebSocket URL and subprotocols.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="url">
|
||||
/// A <see cref="string"/> that contains a WebSocket URL.
|
||||
/// A <see cref="string"/> that contains a WebSocket URL to connect.
|
||||
/// </param>
|
||||
/// <param name="protocols">
|
||||
/// An array of <see cref="string"/> that contains the WebSocket subprotocols if any.
|
||||
@ -166,7 +166,7 @@ namespace WebSocketSharp {
|
||||
/// establishes a WebSocket connection.
|
||||
/// </remarks>
|
||||
/// <param name="url">
|
||||
/// A <see cref="string"/> that contains a WebSocket URL.
|
||||
/// A <see cref="string"/> that contains a WebSocket URL to connect.
|
||||
/// </param>
|
||||
/// <param name="onOpen">
|
||||
/// An <see cref="OnOpen"/> event handler.
|
||||
@ -241,7 +241,8 @@ namespace WebSocketSharp {
|
||||
/// Gets the extensions selected by the server.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="string"/> that contains the extensions if any. By default, <c>String.Empty</c>. (Currently this will only ever be the <c>String.Empty</c>.)
|
||||
/// 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 {
|
||||
@ -276,6 +277,47 @@ namespace WebSocketSharp {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the Origin header used in the WebSocket opening handshake.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A <see cref="WebSocket"/> instance does not send the Origin header in the WebSocket opening handshake
|
||||
/// if the value of this property is <see cref="String.Empty"/>.
|
||||
/// </remarks>
|
||||
/// <value>
|
||||
/// <para>
|
||||
/// A <see cref="string"/> that contains the value of the <see href="http://tools.ietf.org/html/rfc6454#section-7">HTTP Origin header</see> to send.
|
||||
/// The default is <see cref="String.Empty"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The value of the Origin header has the following syntax: <c><scheme>://<host>[:<port>]</c>
|
||||
/// </para>
|
||||
/// </value>
|
||||
public string Origin {
|
||||
get {
|
||||
return _origin;
|
||||
}
|
||||
|
||||
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 (!msg.IsEmpty())
|
||||
{
|
||||
onError(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
_origin = origin.IsNull()
|
||||
? String.Empty
|
||||
: value.TrimEnd('/');
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the subprotocol selected by the server.
|
||||
/// </summary>
|
||||
@ -517,6 +559,8 @@ 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);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -867,17 +867,16 @@
|
||||
Implements the WebSocket interface.
|
||||
</summary>
|
||||
<remarks>
|
||||
The WebSocket class provides methods and properties for two-way communication using the WebSocket protocol (RFC 6455).
|
||||
The WebSocket class provides a set of methods and properties for two-way communication
|
||||
using the WebSocket protocol (<see href="http://tools.ietf.org/html/rfc6455">RFC 6455</see>).
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:WebSocketSharp.WebSocket.#ctor(System.String,System.String[])">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:WebSocketSharp.WebSocket" /> class with the specified WebSocket URL and subprotocols.
|
||||
</summary>
|
||||
<remarks>
|
||||
</remarks>
|
||||
<param name="url">
|
||||
A <see cref="T:System.String" /> that contains a WebSocket URL.
|
||||
A <see cref="T:System.String" /> that contains a WebSocket URL to connect.
|
||||
</param>
|
||||
<param name="protocols">
|
||||
An array of <see cref="T:System.String" /> that contains the WebSocket subprotocols if any.
|
||||
@ -899,7 +898,7 @@
|
||||
establishes a WebSocket connection.
|
||||
</remarks>
|
||||
<param name="url">
|
||||
A <see cref="T:System.String" /> that contains a WebSocket URL.
|
||||
A <see cref="T:System.String" /> that contains a WebSocket URL to connect.
|
||||
</param>
|
||||
<param name="onOpen">
|
||||
An <see cref="E:WebSocketSharp.WebSocket.OnOpen" /> event handler.
|
||||
@ -957,7 +956,8 @@
|
||||
Gets the extensions selected by the server.
|
||||
</summary>
|
||||
<value>
|
||||
A <see cref="T:System.String" /> that contains the extensions if any. By default, <c>String.Empty</c>. (Currently this will only ever be the <c>String.Empty</c>.)
|
||||
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">
|
||||
@ -976,6 +976,23 @@
|
||||
<c>true</c> if the connection is secure; otherwise, <c>false</c>.
|
||||
</value>
|
||||
</member>
|
||||
<member name="P:WebSocketSharp.WebSocket.Origin">
|
||||
<summary>
|
||||
Gets or sets the value of the Origin header used in the WebSocket opening handshake.
|
||||
</summary>
|
||||
<remarks>
|
||||
A <see cref="T:WebSocketSharp.WebSocket" /> instance does not send the Origin header in the WebSocket opening handshake
|
||||
if the value of this property is <see cref="F:System.String.Empty" />.
|
||||
</remarks>
|
||||
<value>
|
||||
<para>
|
||||
A <see cref="T:System.String" /> that contains the value of the <see href="http://tools.ietf.org/html/rfc6454#section-7">HTTP Origin header</see> to send.
|
||||
The default is <see cref="F:System.String.Empty" />.
|
||||
</para>
|
||||
<para>
|
||||
The value of the Origin header has the following syntax: <c><scheme>://<host>[:<port>]</c></para>
|
||||
</value>
|
||||
</member>
|
||||
<member name="P:WebSocketSharp.WebSocket.Protocol">
|
||||
<summary>
|
||||
Gets the subprotocol selected by the server.
|
||||
|
@ -216,7 +216,8 @@
|
||||
<div class="Remarks" id="T:WebSocketSharp.WebSocket:Docs">
|
||||
<h2 class="Section">Remarks</h2>
|
||||
<div class="SectionBox" id="T:WebSocketSharp.WebSocket:Docs:Remarks">
|
||||
The WebSocket class provides methods and properties for two-way communication using the WebSocket protocol (RFC 6455).
|
||||
The WebSocket class provides a set of methods and properties for two-way communication
|
||||
using the WebSocket protocol (RFC 6455).
|
||||
</div>
|
||||
<h2 class="Section">Requirements</h2>
|
||||
<div class="SectionBox" id="T:WebSocketSharp.WebSocket:Docs:Version Information">
|
||||
@ -323,6 +324,23 @@
|
||||
<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.
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<b>
|
||||
<a href="#P:WebSocketSharp.WebSocket.Origin">Origin</a>
|
||||
</b>
|
||||
</td>
|
||||
<td>
|
||||
<i>
|
||||
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>
|
||||
</i>.
|
||||
Gets or sets the value of the Origin header used in the WebSocket opening handshake.
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
@ -685,7 +703,7 @@
|
||||
<i>url</i>
|
||||
</dt>
|
||||
<dd>
|
||||
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains a WebSocket URL.
|
||||
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains a WebSocket URL to connect.
|
||||
</dd>
|
||||
<dt>
|
||||
<i>protocols</i>
|
||||
@ -743,7 +761,7 @@
|
||||
<i>url</i>
|
||||
</dt>
|
||||
<dd>
|
||||
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains a WebSocket URL.
|
||||
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains a WebSocket URL to connect.
|
||||
</dd>
|
||||
<dt>
|
||||
<i>onOpen</i>
|
||||
@ -1016,7 +1034,8 @@
|
||||
<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. By default, <tt>String.Empty</tt>. (Currently this will only ever be the <tt>String.Empty</tt>.)
|
||||
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">
|
||||
@ -1131,6 +1150,32 @@
|
||||
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
|
||||
<hr size="1" />
|
||||
</blockquote>
|
||||
<h3 id="P:WebSocketSharp.WebSocket.Origin">Origin Property</h3>
|
||||
<blockquote id="P:WebSocketSharp.WebSocket.Origin:member">
|
||||
<p class="Summary">
|
||||
Gets or sets the value of the Origin header used in the WebSocket opening handshake.
|
||||
</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>Origin</b> { get; set; }</div>
|
||||
<h4 class="Subsection">Value</h4>
|
||||
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WebSocket.Origin:Value">
|
||||
<p>
|
||||
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains the value of the HTTP Origin header to send.
|
||||
The default is <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>.
|
||||
</p>
|
||||
<p>
|
||||
The value of the Origin header has the following syntax: <tt><scheme>://<host>[:<port>]</tt></p>
|
||||
</blockquote>
|
||||
<h2 class="Section">Remarks</h2>
|
||||
<div class="SectionBox" id="P:WebSocketSharp.WebSocket.Origin:Remarks">
|
||||
A <a href="../WebSocketSharp/WebSocket.html">WebSocketSharp.WebSocket</a> instance does not send the Origin header in the WebSocket opening handshake
|
||||
if the value of this property is <a href="http://www.go-mono.com/docs/monodoc.ashx?link=F:System.String.Empty">string.Empty</a>.
|
||||
</div>
|
||||
<h2 class="Section">Requirements</h2>
|
||||
<div class="SectionBox" id="P:WebSocketSharp.WebSocket.Origin: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.Ping">Ping Method</h3>
|
||||
<blockquote id="M:WebSocketSharp.WebSocket.Ping:member">
|
||||
<p class="Summary">
|
||||
|
@ -17,7 +17,8 @@
|
||||
Implements the WebSocket interface.
|
||||
</summary>
|
||||
<remarks>
|
||||
The WebSocket class provides methods and properties for two-way communication using the WebSocket protocol (RFC 6455).
|
||||
The WebSocket class provides a set of methods and properties for two-way communication
|
||||
using the WebSocket protocol (<see href="http://tools.ietf.org/html/rfc6455">RFC 6455</see>).
|
||||
</remarks>
|
||||
</Docs>
|
||||
<Members>
|
||||
@ -37,7 +38,7 @@
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<param name="url">
|
||||
A <see cref="T:System.String" /> that contains a WebSocket URL.
|
||||
A <see cref="T:System.String" /> that contains a WebSocket URL to connect.
|
||||
</param>
|
||||
<param name="protocols">
|
||||
An array of <see cref="T:System.String" /> that contains the WebSocket subprotocols if any.
|
||||
@ -74,7 +75,7 @@
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<param name="url">
|
||||
A <see cref="T:System.String" /> that contains a WebSocket URL.
|
||||
A <see cref="T:System.String" /> that contains a WebSocket URL to connect.
|
||||
</param>
|
||||
<param name="onOpen">
|
||||
An <see cref="E:WebSocketSharp.WebSocket.OnOpen" /> event handler.
|
||||
@ -282,7 +283,8 @@
|
||||
Gets the extensions selected by the server.
|
||||
</summary>
|
||||
<value>
|
||||
A <see cref="T:System.String" /> that contains the extensions if any. By default, <c>String.Empty</c>. (Currently this will only ever be the <c>String.Empty</c>.)
|
||||
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>
|
||||
@ -377,6 +379,31 @@
|
||||
<remarks>To be added.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="Origin">
|
||||
<MemberSignature Language="C#" Value="public string Origin { get; set; }" />
|
||||
<MemberSignature Language="ILAsm" Value=".property instance string Origin" />
|
||||
<MemberType>Property</MemberType>
|
||||
<ReturnValue>
|
||||
<ReturnType>System.String</ReturnType>
|
||||
</ReturnValue>
|
||||
<Docs>
|
||||
<summary>
|
||||
Gets or sets the value of the Origin header used in the WebSocket opening handshake.
|
||||
</summary>
|
||||
<value>
|
||||
<para>
|
||||
A <see cref="T:System.String" /> that contains the value of the <see href="http://tools.ietf.org/html/rfc6454#section-7">HTTP Origin header</see> to send.
|
||||
The default is <see cref="F:System.String.Empty" />.
|
||||
</para>
|
||||
<para>
|
||||
The value of the Origin header has the following syntax: <c><scheme>://<host>[:<port>]</c></para>
|
||||
</value>
|
||||
<remarks>
|
||||
A <see cref="T:WebSocketSharp.WebSocket" /> instance does not send the Origin header in the WebSocket opening handshake
|
||||
if the value of this property is <see cref="F:System.String.Empty" />.
|
||||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="Ping">
|
||||
<MemberSignature Language="C#" Value="public bool Ping ();" />
|
||||
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance bool Ping() cil managed" />
|
||||
|
@ -1,6 +1,6 @@
|
||||
<Overview>
|
||||
<Assemblies>
|
||||
<Assembly Name="websocket-sharp" Version="1.0.2.24787">
|
||||
<Assembly Name="websocket-sharp" Version="1.0.2.42633">
|
||||
<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>
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user