Visual Studio Reformat: SocketHttpListener

This commit is contained in:
Erwin de Haan 2019-01-13 20:27:29 +01:00
parent 9014e16037
commit 8fd0bc63b9
53 changed files with 946 additions and 1042 deletions

View file

@ -23,16 +23,16 @@ namespace SocketHttpListener
#region Internal Constructors #region Internal Constructors
internal CloseEventArgs (PayloadData payload) internal CloseEventArgs(PayloadData payload)
{ {
var data = payload.ApplicationData; var data = payload.ApplicationData;
var len = data.Length; var len = data.Length;
_code = len > 1 _code = len > 1
? data.SubArray (0, 2).ToUInt16 (ByteOrder.Big) ? data.SubArray(0, 2).ToUInt16(ByteOrder.Big)
: (ushort) CloseStatusCode.NoStatusCode; : (ushort)CloseStatusCode.NoStatusCode;
_reason = len > 2 _reason = len > 2
? GetUtf8String(data.SubArray (2, len - 2)) ? GetUtf8String(data.SubArray(2, len - 2))
: string.Empty; : string.Empty;
} }
@ -51,8 +51,10 @@ namespace SocketHttpListener
/// <value> /// <value>
/// A <see cref="ushort"/> that represents the status code for the close if any. /// A <see cref="ushort"/> that represents the status code for the close if any.
/// </value> /// </value>
public ushort Code { public ushort Code
get { {
get
{
return _code; return _code;
} }
} }
@ -63,8 +65,10 @@ namespace SocketHttpListener
/// <value> /// <value>
/// A <see cref="string"/> that represents the reason for the close if any. /// A <see cref="string"/> that represents the reason for the close if any.
/// </value> /// </value>
public string Reason { public string Reason
get { {
get
{
return _reason; return _reason;
} }
} }
@ -75,12 +79,15 @@ namespace SocketHttpListener
/// <value> /// <value>
/// <c>true</c> if the WebSocket connection has been closed cleanly; otherwise, <c>false</c>. /// <c>true</c> if the WebSocket connection has been closed cleanly; otherwise, <c>false</c>.
/// </value> /// </value>
public bool WasClean { public bool WasClean
get { {
get
{
return _clean; return _clean;
} }
internal set { internal set
{
_clean = value; _clean = value;
} }
} }

View file

@ -20,7 +20,7 @@ namespace SocketHttpListener
#region Internal Constructors #region Internal Constructors
internal ErrorEventArgs (string message) internal ErrorEventArgs(string message)
{ {
_message = message; _message = message;
} }
@ -35,8 +35,10 @@ namespace SocketHttpListener
/// <value> /// <value>
/// A <see cref="string"/> that represents the error message. /// A <see cref="string"/> that represents the error message.
/// </value> /// </value>
public string Message { public string Message
get { {
get
{
return _message; return _message;
} }
} }

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Net; using System.Net;
@ -441,7 +440,8 @@ namespace SocketHttpListener
continue; continue;
} }
} }
else { else
{
} }
buffer.Append(c); buffer.Append(c);

View file

@ -1,9 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Text; using System.Text;
using System.Threading;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
namespace SocketHttpListener namespace SocketHttpListener

View file

@ -1,13 +1,11 @@
using System; using System;
using System.Collections.Specialized; using System.Linq;
using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using HttpStatusCode = SocketHttpListener.Net.HttpStatusCode;
using HttpVersion = SocketHttpListener.Net.HttpVersion;
using System.Linq;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using SocketHttpListener.Net; using SocketHttpListener.Net;
using HttpStatusCode = SocketHttpListener.Net.HttpStatusCode;
using HttpVersion = SocketHttpListener.Net.HttpVersion;
namespace SocketHttpListener namespace SocketHttpListener
{ {

View file

@ -24,18 +24,18 @@ namespace SocketHttpListener
#region Internal Constructors #region Internal Constructors
internal MessageEventArgs (Opcode opcode, byte[] data) internal MessageEventArgs(Opcode opcode, byte[] data)
{ {
_opcode = opcode; _opcode = opcode;
_rawData = data; _rawData = data;
_data = convertToString (opcode, data); _data = convertToString(opcode, data);
} }
internal MessageEventArgs (Opcode opcode, PayloadData payload) internal MessageEventArgs(Opcode opcode, PayloadData payload)
{ {
_opcode = opcode; _opcode = opcode;
_rawData = payload.ApplicationData; _rawData = payload.ApplicationData;
_data = convertToString (opcode, _rawData); _data = convertToString(opcode, _rawData);
} }
#endregion #endregion
@ -48,8 +48,10 @@ namespace SocketHttpListener
/// <value> /// <value>
/// A <see cref="string"/> that contains the received data. /// A <see cref="string"/> that contains the received data.
/// </value> /// </value>
public string Data { public string Data
get { {
get
{
return _data; return _data;
} }
} }
@ -60,8 +62,10 @@ namespace SocketHttpListener
/// <value> /// <value>
/// An array of <see cref="byte"/> that contains the received data. /// An array of <see cref="byte"/> that contains the received data.
/// </value> /// </value>
public byte [] RawData { public byte[] RawData
get { {
get
{
return _rawData; return _rawData;
} }
} }
@ -72,8 +76,10 @@ namespace SocketHttpListener
/// <value> /// <value>
/// One of the <see cref="Opcode"/> values, indicates the type of the received data. /// One of the <see cref="Opcode"/> values, indicates the type of the received data.
/// </value> /// </value>
public Opcode Type { public Opcode Type
get { {
get
{
return _opcode; return _opcode;
} }
} }
@ -82,13 +88,13 @@ namespace SocketHttpListener
#region Private Methods #region Private Methods
private static string convertToString (Opcode opcode, byte [] data) private static string convertToString(Opcode opcode, byte[] data)
{ {
return data.Length == 0 return data.Length == 0
? string.Empty ? string.Empty
: opcode == Opcode.Text : opcode == Opcode.Text
? Encoding.UTF8.GetString (data, 0, data.Length) ? Encoding.UTF8.GetString(data, 0, data.Length)
: opcode.ToString (); : opcode.ToString();
} }
#endregion #endregion

View file

@ -1,8 +1,4 @@
using System; namespace SocketHttpListener.Net
using System.Collections.Generic;
using System.Text;
namespace SocketHttpListener.Net
{ {
internal class AuthenticationTypes internal class AuthenticationTypes
{ {

View file

@ -1,9 +1,4 @@
using System; namespace SocketHttpListener.Net
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SocketHttpListener.Net
{ {
internal enum BoundaryType internal enum BoundaryType
{ {

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;

View file

@ -1,8 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Runtime.InteropServices;
using SocketHttpListener.Primitives;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,9 +1,4 @@
using System; namespace SocketHttpListener.Net
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SocketHttpListener.Net
{ {
internal enum EntitySendFormat internal enum EntitySendFormat
{ {

View file

@ -3,19 +3,17 @@ using System.IO;
using System.Net; using System.Net;
using System.Net.Security; using System.Net.Security;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using MediaBrowser.Model.Text; using MediaBrowser.Model.Text;
using Microsoft.Extensions.Logging;
using SocketHttpListener.Primitives; using SocketHttpListener.Primitives;
using System.Security.Authentication;
using System.Threading;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {
sealed class HttpConnection sealed class HttpConnection

View file

@ -1,21 +1,15 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Threading; using System.Threading;
using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using MediaBrowser.Model.Text; using MediaBrowser.Model.Text;
using SocketHttpListener.Primitives; using Microsoft.Extensions.Logging;
using ProtocolType = MediaBrowser.Model.Net.ProtocolType;
using SocketType = MediaBrowser.Model.Net.SocketType;
using System.Threading.Tasks;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {
@ -209,7 +203,7 @@ namespace SocketHttpListener.Net
return; return;
} }
if(accepted == null) if (accepted == null)
{ {
return; return;
} }

View file

@ -3,12 +3,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Reflection;
using System.Threading.Tasks;
using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Net;
using SocketHttpListener.Primitives;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,8 +1,4 @@
using System; namespace SocketHttpListener.Net
using System.Collections.Generic;
using System.Text;
namespace SocketHttpListener.Net
{ {
internal static partial class HttpKnownHeaderNames internal static partial class HttpKnownHeaderNames
{ {

View file

@ -1,17 +1,15 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Net; using System.Net;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using MediaBrowser.Model.Text; using MediaBrowser.Model.Text;
using SocketHttpListener.Primitives; using Microsoft.Extensions.Logging;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,8 +1,8 @@
using System.ComponentModel; using System;
using System.ComponentModel;
using System.Security.Principal; using System.Security.Principal;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System;
using MediaBrowser.Model.Text; using MediaBrowser.Model.Text;
using SocketHttpListener.Net.WebSockets; using SocketHttpListener.Net.WebSockets;

View file

@ -1,12 +1,8 @@
using System; using System;
using System.Net; using System.Net;
using System.Security.Principal; using System.Security.Principal;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Text;
using SocketHttpListener.Net.WebSockets;
using System.Threading.Tasks; using System.Threading.Tasks;
using SocketHttpListener.Net.WebSockets;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,12 +1,7 @@
using System; using System;
using System.Text;
using System.Collections.Specialized;
using System.Globalization;
using System.IO; using System.IO;
using System.Security.Authentication.ExtendedProtection; using System.Text;
using System.Security.Cryptography.X509Certificates;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using MediaBrowser.Model.Text;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,17 +1,11 @@
using System; using System;
using System.Collections.Specialized;
using System.Globalization;
using System.IO;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.Text;
using SocketHttpListener.Primitives;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Text;
using MediaBrowser.Model.Services;
using SocketHttpListener.Net.WebSockets; using SocketHttpListener.Net.WebSockets;
using SocketHttpListener.Primitives;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,8 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Text;
using System.Globalization; using System.Globalization;
using System.Text;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,14 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Text; using MediaBrowser.Model.Text;
using SocketHttpListener.Primitives; using SocketHttpListener.Primitives;
using System.Threading;
using MediaBrowser.Model.IO;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,14 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Diagnostics;
using Microsoft.Win32.SafeHandles;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,9 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading.Tasks;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;

View file

@ -1,15 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Runtime.ExceptionServices;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using Microsoft.Extensions.Logging;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;

View file

@ -1,9 +1,4 @@
using System; namespace SocketHttpListener.Net
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SocketHttpListener.Net
{ {
internal static class HttpStatusDescription internal static class HttpStatusDescription
{ {

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Net; using System.Net;
using MediaBrowser.Model.Net;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,8 +1,4 @@
using System; namespace SocketHttpListener.Net
using System.Collections.Generic;
using System.Text;
namespace SocketHttpListener.Net
{ {
internal static class UriScheme internal static class UriScheme
{ {

View file

@ -1,13 +1,8 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using MediaBrowser.Model.Extensions;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,7 +1,4 @@
using System; using System.Text;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SocketHttpListener.Net namespace SocketHttpListener.Net
{ {

View file

@ -1,14 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Net; using System.Net;
using System.Security.Principal; using System.Security.Principal;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using SocketHttpListener.Primitives;
namespace SocketHttpListener.Net.WebSockets namespace SocketHttpListener.Net.WebSockets
{ {

View file

@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SocketHttpListener.Net.WebSockets namespace SocketHttpListener.Net.WebSockets

View file

@ -1,8 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text;
using System.Threading; using System.Threading;
namespace SocketHttpListener.Net.WebSockets namespace SocketHttpListener.Net.WebSockets

View file

@ -1,8 +1,4 @@
using System; namespace SocketHttpListener.Net.WebSockets
using System.Collections.Generic;
using System.Text;
namespace SocketHttpListener.Net.WebSockets
{ {
public enum WebSocketCloseStatus public enum WebSocketCloseStatus
{ {

View file

@ -1,9 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net; using System.Net;
using System.Security.Principal; using System.Security.Principal;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
namespace SocketHttpListener.Net.WebSockets namespace SocketHttpListener.Net.WebSockets

View file

@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using MediaBrowser.Model.Net;
using System.Globalization; using System.Globalization;
using System.Text;
using WebSocketState = System.Net.WebSockets.WebSocketState; using WebSocketState = System.Net.WebSockets.WebSocketState;
namespace SocketHttpListener.Net.WebSockets namespace SocketHttpListener.Net.WebSockets

View file

@ -9,8 +9,8 @@ namespace SocketHttpListener
{ {
#region Private Fields #region Private Fields
private byte [] _applicationData; private byte[] _applicationData;
private byte [] _extensionData; private byte[] _extensionData;
private bool _masked; private bool _masked;
#endregion #endregion
@ -23,27 +23,27 @@ namespace SocketHttpListener
#region Public Constructors #region Public Constructors
public PayloadData () public PayloadData()
: this (new byte [0], new byte [0], false) : this(new byte[0], new byte[0], false)
{ {
} }
public PayloadData (byte [] applicationData) public PayloadData(byte[] applicationData)
: this (new byte [0], applicationData, false) : this(new byte[0], applicationData, false)
{ {
} }
public PayloadData (string applicationData) public PayloadData(string applicationData)
: this (new byte [0], Encoding.UTF8.GetBytes (applicationData), false) : this(new byte[0], Encoding.UTF8.GetBytes(applicationData), false)
{ {
} }
public PayloadData (byte [] applicationData, bool masked) public PayloadData(byte[] applicationData, bool masked)
: this (new byte [0], applicationData, masked) : this(new byte[0], applicationData, masked)
{ {
} }
public PayloadData (byte [] extensionData, byte [] applicationData, bool masked) public PayloadData(byte[] extensionData, byte[] applicationData, bool masked)
{ {
_extensionData = extensionData; _extensionData = extensionData;
_applicationData = applicationData; _applicationData = applicationData;
@ -54,10 +54,12 @@ namespace SocketHttpListener
#region Internal Properties #region Internal Properties
internal bool ContainsReservedCloseStatusCode { internal bool ContainsReservedCloseStatusCode
get { {
get
{
return _applicationData.Length > 1 && return _applicationData.Length > 1 &&
_applicationData.SubArray (0, 2).ToUInt16 (ByteOrder.Big).IsReserved (); _applicationData.SubArray(0, 2).ToUInt16(ByteOrder.Big).IsReserved();
} }
} }
@ -65,27 +67,35 @@ namespace SocketHttpListener
#region Public Properties #region Public Properties
public byte [] ApplicationData { public byte[] ApplicationData
get { {
get
{
return _applicationData; return _applicationData;
} }
} }
public byte [] ExtensionData { public byte[] ExtensionData
get { {
get
{
return _extensionData; return _extensionData;
} }
} }
public bool IsMasked { public bool IsMasked
get { {
get
{
return _masked; return _masked;
} }
} }
public ulong Length { public ulong Length
get { {
return (ulong) (_extensionData.Length + _applicationData.Length); get
{
return (ulong)(_extensionData.Length + _applicationData.Length);
} }
} }
@ -93,17 +103,17 @@ namespace SocketHttpListener
#region Private Methods #region Private Methods
private static void mask (byte [] src, byte [] key) private static void mask(byte[] src, byte[] key)
{ {
for (long i = 0; i < src.Length; i++) for (long i = 0; i < src.Length; i++)
src [i] = (byte) (src [i] ^ key [i % 4]); src[i] = (byte)(src[i] ^ key[i % 4]);
} }
#endregion #endregion
#region Public Methods #region Public Methods
public IEnumerator<byte> GetEnumerator () public IEnumerator<byte> GetEnumerator()
{ {
foreach (byte b in _extensionData) foreach (byte b in _extensionData)
yield return b; yield return b;
@ -112,36 +122,36 @@ namespace SocketHttpListener
yield return b; yield return b;
} }
public void Mask (byte [] maskingKey) public void Mask(byte[] maskingKey)
{ {
if (_extensionData.Length > 0) if (_extensionData.Length > 0)
mask (_extensionData, maskingKey); mask(_extensionData, maskingKey);
if (_applicationData.Length > 0) if (_applicationData.Length > 0)
mask (_applicationData, maskingKey); mask(_applicationData, maskingKey);
_masked = !_masked; _masked = !_masked;
} }
public byte [] ToByteArray () public byte[] ToByteArray()
{ {
return _extensionData.Length > 0 return _extensionData.Length > 0
? new List<byte> (this).ToArray () ? new List<byte>(this).ToArray()
: _applicationData; : _applicationData;
} }
public override string ToString () public override string ToString()
{ {
return BitConverter.ToString (ToByteArray ()); return BitConverter.ToString(ToByteArray());
} }
#endregion #endregion
#region Explicitly Implemented Interface Members #region Explicitly Implemented Interface Members
IEnumerator IEnumerable.GetEnumerator () IEnumerator IEnumerable.GetEnumerator()
{ {
return GetEnumerator (); return GetEnumerator();
} }
#endregion #endregion

View file

@ -1,7 +1,4 @@
using System; using System.Text;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using MediaBrowser.Model.Text; using MediaBrowser.Model.Text;
namespace SocketHttpListener.Primitives namespace SocketHttpListener.Primitives

View file

@ -1,10 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace SocketHttpListener namespace SocketHttpListener
{ {

View file

@ -3,15 +3,12 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Net.Sockets;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO;
using SocketHttpListener.Net.WebSockets; using SocketHttpListener.Net.WebSockets;
using SocketHttpListener.Primitives;
using HttpStatusCode = SocketHttpListener.Net.HttpStatusCode; using HttpStatusCode = SocketHttpListener.Net.HttpStatusCode;
using System.Net.Sockets;
using WebSocketState = System.Net.WebSockets.WebSocketState; using WebSocketState = System.Net.WebSockets.WebSocketState;
namespace SocketHttpListener namespace SocketHttpListener

View file

@ -9,33 +9,33 @@ namespace SocketHttpListener
{ {
#region Internal Constructors #region Internal Constructors
internal WebSocketException () internal WebSocketException()
: this (CloseStatusCode.Abnormal, null, null) : this(CloseStatusCode.Abnormal, null, null)
{ {
} }
internal WebSocketException (string message) internal WebSocketException(string message)
: this (CloseStatusCode.Abnormal, message, null) : this(CloseStatusCode.Abnormal, message, null)
{ {
} }
internal WebSocketException (CloseStatusCode code) internal WebSocketException(CloseStatusCode code)
: this (code, null, null) : this(code, null, null)
{ {
} }
internal WebSocketException (string message, Exception innerException) internal WebSocketException(string message, Exception innerException)
: this (CloseStatusCode.Abnormal, message, innerException) : this(CloseStatusCode.Abnormal, message, innerException)
{ {
} }
internal WebSocketException (CloseStatusCode code, string message) internal WebSocketException(CloseStatusCode code, string message)
: this (code, message, null) : this(code, message, null)
{ {
} }
internal WebSocketException (CloseStatusCode code, string message, Exception innerException) internal WebSocketException(CloseStatusCode code, string message, Exception innerException)
: base (message ?? code.GetMessage (), innerException) : base(message ?? code.GetMessage(), innerException)
{ {
Code = code; Code = code;
} }
@ -51,7 +51,8 @@ namespace SocketHttpListener
/// One of the <see cref="CloseStatusCode"/> enum values, represents the status code indicating /// One of the <see cref="CloseStatusCode"/> enum values, represents the status code indicating
/// the cause for the exception. /// the cause for the exception.
/// </value> /// </value>
public CloseStatusCode Code { public CloseStatusCode Code
{
get; private set; get; private set;
} }

View file

@ -2,7 +2,6 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
namespace SocketHttpListener namespace SocketHttpListener
{ {