Refactored a few for HttpStreamAsyncResult.cs
This commit is contained in:
parent
0a07e10c90
commit
8793576fba
@ -194,7 +194,7 @@ namespace WebSocketSharp.Net
|
|||||||
if (!ares.IsCompleted)
|
if (!ares.IsCompleted)
|
||||||
ares.AsyncWaitHandle.WaitOne ();
|
ares.AsyncWaitHandle.WaitOne ();
|
||||||
|
|
||||||
if (ares.Error != null)
|
if (ares.HasException)
|
||||||
throw new HttpListenerException (400, "I/O operation aborted.");
|
throw new HttpListenerException (400, "I/O operation aborted.");
|
||||||
|
|
||||||
return ares.Count;
|
return ares.Count;
|
||||||
|
@ -46,27 +46,22 @@ namespace WebSocketSharp.Net
|
|||||||
{
|
{
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
|
private byte[] _buffer;
|
||||||
private AsyncCallback _callback;
|
private AsyncCallback _callback;
|
||||||
private bool _completed;
|
private bool _completed;
|
||||||
|
private int _count;
|
||||||
|
private Exception _exception;
|
||||||
|
private int _offset;
|
||||||
private object _state;
|
private object _state;
|
||||||
private object _sync;
|
private object _sync;
|
||||||
|
private int _syncRead;
|
||||||
private ManualResetEvent _waitHandle;
|
private ManualResetEvent _waitHandle;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Internal Fields
|
#region Internal Constructors
|
||||||
|
|
||||||
internal byte [] Buffer;
|
internal HttpStreamAsyncResult (AsyncCallback callback, object state)
|
||||||
internal int Count;
|
|
||||||
internal Exception Error;
|
|
||||||
internal int Offset;
|
|
||||||
internal int SyncRead;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Constructors
|
|
||||||
|
|
||||||
public HttpStreamAsyncResult (AsyncCallback callback, object state)
|
|
||||||
{
|
{
|
||||||
_callback = callback;
|
_callback = callback;
|
||||||
_state = state;
|
_state = state;
|
||||||
@ -75,6 +70,62 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Internal Properties
|
||||||
|
|
||||||
|
internal byte[] Buffer {
|
||||||
|
get {
|
||||||
|
return _buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
set {
|
||||||
|
_buffer = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal int Count {
|
||||||
|
get {
|
||||||
|
return _count;
|
||||||
|
}
|
||||||
|
|
||||||
|
set {
|
||||||
|
_count = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Exception Exception {
|
||||||
|
get {
|
||||||
|
return _exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool HasException {
|
||||||
|
get {
|
||||||
|
return _exception != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal int Offset {
|
||||||
|
get {
|
||||||
|
return _offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
set {
|
||||||
|
_offset = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal int SyncRead {
|
||||||
|
get {
|
||||||
|
return _syncRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
set {
|
||||||
|
_syncRead = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Public Properties
|
#region Public Properties
|
||||||
|
|
||||||
public object AsyncState {
|
public object AsyncState {
|
||||||
@ -92,7 +143,7 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
public bool CompletedSynchronously {
|
public bool CompletedSynchronously {
|
||||||
get {
|
get {
|
||||||
return SyncRead == Count;
|
return _syncRead == _count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,9 +156,9 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public Methods
|
#region Internal Methods
|
||||||
|
|
||||||
public void Complete ()
|
internal void Complete ()
|
||||||
{
|
{
|
||||||
lock (_sync) {
|
lock (_sync) {
|
||||||
if (_completed)
|
if (_completed)
|
||||||
@ -122,9 +173,9 @@ namespace WebSocketSharp.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Complete (Exception exception)
|
internal void Complete (Exception exception)
|
||||||
{
|
{
|
||||||
Error = exception;
|
_exception = exception;
|
||||||
Complete ();
|
Complete ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user