Modified MessageEventArgs.cs
This commit is contained in:
@@ -35,8 +35,7 @@ namespace WebSocketSharp {
|
||||
/// </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.
|
||||
/// <see href="http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-09">Compression Extensions for WebSocket</see>.
|
||||
/// </remarks>
|
||||
public enum CompressionMethod : byte
|
||||
{
|
||||
|
||||
@@ -41,29 +41,31 @@ namespace WebSocketSharp {
|
||||
/// </remarks>
|
||||
public class MessageEventArgs : EventArgs
|
||||
{
|
||||
#region Fields
|
||||
#region Private Fields
|
||||
|
||||
private PayloadData _data;
|
||||
private Opcode _type;
|
||||
private byte[] _data;
|
||||
private Opcode _opcode;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
#region Internal Constructors
|
||||
|
||||
internal MessageEventArgs(Opcode type, byte[] data)
|
||||
: this(type, new PayloadData(data))
|
||||
internal MessageEventArgs(Opcode opcode, byte[] data)
|
||||
{
|
||||
if ((ulong)data.LongLength > PayloadData.MaxLength)
|
||||
throw new WebSocketException(CloseStatusCode.TOO_BIG);
|
||||
|
||||
init(opcode, data);
|
||||
}
|
||||
|
||||
internal MessageEventArgs(Opcode type, PayloadData data)
|
||||
internal MessageEventArgs(Opcode opcode, PayloadData data)
|
||||
{
|
||||
_type = type;
|
||||
_data = data;
|
||||
init(opcode, data.ApplicationData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the received data as a <see cref="string"/>.
|
||||
@@ -73,11 +75,11 @@ namespace WebSocketSharp {
|
||||
/// </value>
|
||||
public string Data {
|
||||
get {
|
||||
return _type == Opcode.TEXT || _type == Opcode.PING || _type == Opcode.PONG
|
||||
? _data.Length > 0
|
||||
? Encoding.UTF8.GetString(_data.ToByteArray())
|
||||
return _opcode == Opcode.TEXT || _opcode == Opcode.PING || _opcode == Opcode.PONG
|
||||
? _data.LongLength > 0
|
||||
? Encoding.UTF8.GetString(_data)
|
||||
: String.Empty
|
||||
: _type.ToString();
|
||||
: _opcode.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +91,7 @@ namespace WebSocketSharp {
|
||||
/// </value>
|
||||
public byte[] RawData {
|
||||
get {
|
||||
return _data.ToByteArray();
|
||||
return _data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,10 +103,20 @@ namespace WebSocketSharp {
|
||||
/// </value>
|
||||
public Opcode Type {
|
||||
get {
|
||||
return _type;
|
||||
return _opcode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void init(Opcode opcode, byte[] data)
|
||||
{
|
||||
_opcode = opcode;
|
||||
_data = data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -930,11 +930,12 @@ namespace WebSocketSharp {
|
||||
if (frame.IsCompressed && _compression == CompressionMethod.NONE)
|
||||
return false;
|
||||
|
||||
var data = frame.IsCompressed
|
||||
? new PayloadData(frame.PayloadData.ApplicationData.Decompress(_compression))
|
||||
: frame.PayloadData;
|
||||
var args = frame.IsCompressed
|
||||
? new MessageEventArgs(
|
||||
frame.Opcode, frame.PayloadData.ApplicationData.Decompress(_compression))
|
||||
: new MessageEventArgs(frame.Opcode, frame.PayloadData);
|
||||
|
||||
onMessage(new MessageEventArgs(frame.Opcode, data));
|
||||
onMessage(args);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -830,19 +830,6 @@
|
||||
<c>true</c> if the WebSocket connection closed cleanly; otherwise, <c>false</c>.
|
||||
</value>
|
||||
</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">
|
||||
<summary>
|
||||
Contains the values that indicate whether the byte order is a Little-endian or Big-endian.
|
||||
@@ -5197,8 +5184,7 @@
|
||||
</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.
|
||||
<see href="http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-09">Compression Extensions for WebSocket</see>.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="F:WebSocketSharp.CompressionMethod.NONE">
|
||||
@@ -5211,5 +5197,18 @@
|
||||
Indicates using DEFLATE.
|
||||
</summary>
|
||||
</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>
|
||||
</members>
|
||||
</doc>
|
||||
|
||||
@@ -217,8 +217,7 @@
|
||||
<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.
|
||||
Compression Extensions for WebSocket.
|
||||
</div>
|
||||
<h2 class="Section">Members</h2>
|
||||
<div class="SectionBox" id="T:WebSocketSharp.CompressionMethod:Docs:Members">
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
</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.
|
||||
<see href="http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-09">Compression Extensions for WebSocket</see>.
|
||||
</remarks>
|
||||
</Docs>
|
||||
<Members>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Overview>
|
||||
<Assemblies>
|
||||
<Assembly Name="websocket-sharp" Version="1.0.2.28778">
|
||||
<Assembly Name="websocket-sharp" Version="1.0.2.41941">
|
||||
<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.
Reference in New Issue
Block a user