diff --git a/Example/bin/Debug_Ubuntu/example.exe b/Example/bin/Debug_Ubuntu/example.exe index ae0fcc53..60976ef5 100755 Binary files a/Example/bin/Debug_Ubuntu/example.exe and b/Example/bin/Debug_Ubuntu/example.exe differ diff --git a/Example/bin/Debug_Ubuntu/example.exe.mdb b/Example/bin/Debug_Ubuntu/example.exe.mdb index d4d54a68..fb55a479 100644 Binary files a/Example/bin/Debug_Ubuntu/example.exe.mdb and b/Example/bin/Debug_Ubuntu/example.exe.mdb differ diff --git a/Example/bin/Debug_Ubuntu/websocket-sharp.dll b/Example/bin/Debug_Ubuntu/websocket-sharp.dll index 8d4abd94..9347d87b 100755 Binary files a/Example/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 47173344..169caa6b 100644 Binary files a/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/Example1/bin/Debug_Ubuntu/example1.exe b/Example1/bin/Debug_Ubuntu/example1.exe index b6e782c1..1539fe27 100755 Binary files a/Example1/bin/Debug_Ubuntu/example1.exe and b/Example1/bin/Debug_Ubuntu/example1.exe differ diff --git a/Example1/bin/Debug_Ubuntu/example1.exe.mdb b/Example1/bin/Debug_Ubuntu/example1.exe.mdb index 53855b1c..d6be9cec 100644 Binary files a/Example1/bin/Debug_Ubuntu/example1.exe.mdb and b/Example1/bin/Debug_Ubuntu/example1.exe.mdb differ diff --git a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll index 8d4abd94..9347d87b 100755 Binary files a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 47173344..169caa6b 100644 Binary files a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/Example2/bin/Debug_Ubuntu/example2.exe b/Example2/bin/Debug_Ubuntu/example2.exe index 2c07854c..3c59e210 100755 Binary files a/Example2/bin/Debug_Ubuntu/example2.exe and b/Example2/bin/Debug_Ubuntu/example2.exe differ diff --git a/Example2/bin/Debug_Ubuntu/example2.exe.mdb b/Example2/bin/Debug_Ubuntu/example2.exe.mdb index 28336364..60515c93 100644 Binary files a/Example2/bin/Debug_Ubuntu/example2.exe.mdb and b/Example2/bin/Debug_Ubuntu/example2.exe.mdb differ diff --git a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll index 8d4abd94..9347d87b 100755 Binary files a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 47173344..169caa6b 100644 Binary files a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/Example3/bin/Debug_Ubuntu/Example3.exe b/Example3/bin/Debug_Ubuntu/Example3.exe index 9d8ca3f5..7b0dbb14 100755 Binary files a/Example3/bin/Debug_Ubuntu/Example3.exe and b/Example3/bin/Debug_Ubuntu/Example3.exe differ diff --git a/Example3/bin/Debug_Ubuntu/Example3.exe.mdb b/Example3/bin/Debug_Ubuntu/Example3.exe.mdb index 1d97fe79..d7fb78ea 100644 Binary files a/Example3/bin/Debug_Ubuntu/Example3.exe.mdb and b/Example3/bin/Debug_Ubuntu/Example3.exe.mdb differ diff --git a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll index 8d4abd94..9347d87b 100755 Binary files a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 47173344..169caa6b 100644 Binary files a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 79fa8d7d..e5fc3614 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -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(ByteOrder.BIG) + ? data.ToByteArray().SubArray(0, 2).To(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); } diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 0592aba0..73cbc531 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -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 { /// public byte[] RawData { get { - return _data.ToBytes(); + return _data.ToByteArray(); } } diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 13e8d031..59ed47ed 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -1,4 +1,4 @@ -#region MIT License +#region License /* * PayloadData.cs * @@ -36,16 +36,16 @@ namespace WebSocketSharp { internal class PayloadData : IEnumerable { - #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(ByteOrder.BIG); + var code = ToByteArray().SubArray(0, 2).To(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 diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e8f4eab0..a1584c24 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -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(first.PayloadData.ToBytes()); + var buffer = new List(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; } diff --git a/websocket-sharp/WsFrame.cs b/websocket-sharp/WsFrame.cs index f7fd43b7..17b5f5db 100644 --- a/websocket-sharp/WsFrame.cs +++ b/websocket-sharp/WsFrame.cs @@ -1,4 +1,4 @@ -#region MIT License +#region License /* * WsFrame.cs * @@ -36,13 +36,13 @@ namespace WebSocketSharp { internal class WsFrame : IEnumerable { - #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(); } diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll index 8d4abd94..9347d87b 100755 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 47173344..169caa6b 100644 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/websocket-sharp/websocket-sharp.pidb b/websocket-sharp/websocket-sharp.pidb index d3431952..e986d6b8 100644 Binary files a/websocket-sharp/websocket-sharp.pidb and b/websocket-sharp/websocket-sharp.pidb differ