Fix due to the modified PayloadData.cs
This commit is contained in:
parent
029d1f6d1d
commit
9bf4adfbab
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.
@ -1,4 +1,4 @@
|
||||
#region MIT License
|
||||
#region License
|
||||
/*
|
||||
* CloseEventArgs.cs
|
||||
*
|
||||
@ -49,7 +49,7 @@ namespace WebSocketSharp {
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
#region Constructors
|
||||
|
||||
internal CloseEventArgs(PayloadData data)
|
||||
: base(Opcode.CLOSE, data)
|
||||
@ -110,7 +110,7 @@ namespace WebSocketSharp {
|
||||
private ushort getCodeFrom(PayloadData data)
|
||||
{
|
||||
return data.Length >= 2
|
||||
? data.ToBytes().SubArray(0, 2).To<ushort>(ByteOrder.BIG)
|
||||
? data.ToByteArray().SubArray(0, 2).To<ushort>(ByteOrder.BIG)
|
||||
: (ushort)CloseStatusCode.NO_STATUS_CODE;
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ namespace WebSocketSharp {
|
||||
if (data.Length <= 2)
|
||||
return String.Empty;
|
||||
|
||||
var buffer = data.ToBytes().SubArray(2, (int)(data.Length - 2));
|
||||
var buffer = data.ToByteArray().SubArray(2, (int)(data.Length - 2));
|
||||
return Encoding.UTF8.GetString(buffer);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#region MIT License
|
||||
#region License
|
||||
/*
|
||||
* MessageEventArgs.cs
|
||||
*
|
||||
@ -48,7 +48,7 @@ namespace WebSocketSharp {
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
#region Constructors
|
||||
|
||||
internal MessageEventArgs(Opcode type, PayloadData data)
|
||||
{
|
||||
@ -70,7 +70,7 @@ namespace WebSocketSharp {
|
||||
get {
|
||||
return ((Opcode.TEXT | Opcode.PING | Opcode.PONG) & _type) == _type
|
||||
? _data.Length > 0
|
||||
? Encoding.UTF8.GetString(_data.ToBytes())
|
||||
? Encoding.UTF8.GetString(_data.ToByteArray())
|
||||
: String.Empty
|
||||
: _type.ToString();
|
||||
}
|
||||
@ -84,7 +84,7 @@ namespace WebSocketSharp {
|
||||
/// </value>
|
||||
public byte[] RawData {
|
||||
get {
|
||||
return _data.ToBytes();
|
||||
return _data.ToByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#region MIT License
|
||||
#region License
|
||||
/*
|
||||
* PayloadData.cs
|
||||
*
|
||||
@ -36,16 +36,16 @@ namespace WebSocketSharp {
|
||||
|
||||
internal class PayloadData : IEnumerable<byte>
|
||||
{
|
||||
#region Field
|
||||
#region Fields
|
||||
|
||||
public const ulong MaxLength = long.MaxValue;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Constructors
|
||||
#region Constructors
|
||||
|
||||
public PayloadData(string appData)
|
||||
: this(Encoding.UTF8.GetBytes(appData))
|
||||
public PayloadData()
|
||||
: this(new byte[]{})
|
||||
{
|
||||
}
|
||||
|
||||
@ -54,6 +54,11 @@ namespace WebSocketSharp {
|
||||
{
|
||||
}
|
||||
|
||||
public PayloadData(string appData)
|
||||
: this(Encoding.UTF8.GetBytes(appData))
|
||||
{
|
||||
}
|
||||
|
||||
public PayloadData(byte[] appData, bool masked)
|
||||
: this(new byte[]{}, appData, masked)
|
||||
{
|
||||
@ -73,22 +78,23 @@ namespace WebSocketSharp {
|
||||
throw new ArgumentNullException("appData");
|
||||
|
||||
if ((ulong)extData.LongLength + (ulong)appData.LongLength > MaxLength)
|
||||
throw new ArgumentOutOfRangeException("Plus 'extData' length and 'appData' lenght must be less than MaxLength.");
|
||||
throw new ArgumentOutOfRangeException(
|
||||
"The length of 'extData' plus 'appData' must be less than MaxLength.");
|
||||
|
||||
ExtensionData = extData;
|
||||
ExtensionData = extData;
|
||||
ApplicationData = appData;
|
||||
IsMasked = masked;
|
||||
IsMasked = masked;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Property
|
||||
#region Internal Properties
|
||||
|
||||
internal bool ContainsReservedCloseStatusCode {
|
||||
get {
|
||||
if (Length >= 2)
|
||||
{
|
||||
var code = ToBytes().SubArray(0, 2).To<ushort>(ByteOrder.BIG);
|
||||
var code = ToByteArray().SubArray(0, 2).To<ushort>(ByteOrder.BIG);
|
||||
if (code == (ushort)CloseStatusCode.UNDEFINED ||
|
||||
code == (ushort)CloseStatusCode.NO_STATUS_CODE ||
|
||||
code == (ushort)CloseStatusCode.ABNORMAL ||
|
||||
@ -104,10 +110,10 @@ namespace WebSocketSharp {
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public byte[] ExtensionData { get; private set; }
|
||||
|
||||
public byte[] ApplicationData { get; private set; }
|
||||
|
||||
public byte[] ExtensionData { get; private set; }
|
||||
|
||||
public bool IsMasked { get; private set; }
|
||||
|
||||
public ulong Length {
|
||||
@ -120,12 +126,7 @@ namespace WebSocketSharp {
|
||||
|
||||
#region Private Methods
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
private void mask(byte[] src, byte[] key)
|
||||
private static void mask(byte[] src, byte[] key)
|
||||
{
|
||||
for (long i = 0; i < src.LongLength; i++)
|
||||
src[i] = (byte)(src[i] ^ key[i % 4]);
|
||||
@ -150,7 +151,7 @@ namespace WebSocketSharp {
|
||||
throw new ArgumentNullException("maskingKey");
|
||||
|
||||
if (maskingKey.Length != 4)
|
||||
throw new ArgumentOutOfRangeException("maskingKey", "'maskingKey' length must be 4.");
|
||||
throw new ArgumentOutOfRangeException("maskingKey", "The length must be 4.");
|
||||
|
||||
if (ExtensionData.LongLength > 0)
|
||||
mask(ExtensionData, maskingKey);
|
||||
@ -161,7 +162,7 @@ namespace WebSocketSharp {
|
||||
IsMasked = !IsMasked;
|
||||
}
|
||||
|
||||
public byte[] ToBytes()
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
return ExtensionData.LongLength > 0
|
||||
? ExtensionData.Concat(ApplicationData).ToArray()
|
||||
@ -170,7 +171,16 @@ namespace WebSocketSharp {
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return BitConverter.ToString(ToBytes());
|
||||
return BitConverter.ToString(ToByteArray());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Explicitly Implemented Interface Members
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1,4 +1,4 @@
|
||||
#region MIT License
|
||||
#region License
|
||||
/*
|
||||
* WebSocket.cs
|
||||
*
|
||||
@ -84,7 +84,7 @@ namespace WebSocketSharp {
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Constructor
|
||||
#region Private Constructors
|
||||
|
||||
private WebSocket()
|
||||
{
|
||||
@ -208,7 +208,7 @@ namespace WebSocketSharp {
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Property
|
||||
#region Internal Properties
|
||||
|
||||
internal CookieCollection CookieCollection {
|
||||
get {
|
||||
@ -759,7 +759,7 @@ namespace WebSocketSharp {
|
||||
|
||||
private void processFragments(WsFrame first)
|
||||
{
|
||||
var buffer = new List<byte>(first.PayloadData.ToBytes());
|
||||
var buffer = new List<byte>(first.PayloadData.ToByteArray());
|
||||
while (true)
|
||||
{
|
||||
var frame = readFrame();
|
||||
@ -772,7 +772,7 @@ namespace WebSocketSharp {
|
||||
// MORE & CONT
|
||||
if (frame.Opcode == Opcode.CONT)
|
||||
{
|
||||
buffer.AddRange(frame.PayloadData.ToBytes());
|
||||
buffer.AddRange(frame.PayloadData.ToByteArray());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -784,7 +784,7 @@ namespace WebSocketSharp {
|
||||
// FINAL & CONT
|
||||
if (frame.Opcode == Opcode.CONT)
|
||||
{
|
||||
buffer.AddRange(frame.PayloadData.ToBytes());
|
||||
buffer.AddRange(frame.PayloadData.ToByteArray());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#region MIT License
|
||||
#region License
|
||||
/*
|
||||
* WsFrame.cs
|
||||
*
|
||||
@ -36,13 +36,13 @@ namespace WebSocketSharp {
|
||||
|
||||
internal class WsFrame : IEnumerable<byte>
|
||||
{
|
||||
#region Field
|
||||
#region Fields
|
||||
|
||||
private const int _readBufferLen = 1024;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Constructor
|
||||
#region Private Constructors
|
||||
|
||||
private WsFrame()
|
||||
{
|
||||
@ -380,11 +380,11 @@ namespace WebSocketSharp {
|
||||
Masked == Mask.UNMASK &&
|
||||
PayloadLength > 0)
|
||||
{
|
||||
payloadData = Encoding.UTF8.GetString(PayloadData.ToBytes());
|
||||
payloadData = Encoding.UTF8.GetString(PayloadData.ToByteArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
payloadData = BitConverter.ToString(PayloadData.ToBytes());
|
||||
payloadData = BitConverter.ToString(PayloadData.ToByteArray());
|
||||
}
|
||||
|
||||
headerFmt = @"
|
||||
@ -491,7 +491,7 @@ namespace WebSocketSharp {
|
||||
buffer.AddRange(MaskingKey);
|
||||
|
||||
if (PayloadLen > 0)
|
||||
buffer.AddRange(PayloadData.ToBytes());
|
||||
buffer.AddRange(PayloadData.ToByteArray());
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user