[Modify] Polish it
This commit is contained in:
parent
9d514440bf
commit
39add76329
@ -942,31 +942,20 @@ namespace WebSocketSharp
|
|||||||
this Stream stream, byte[] bytes, int bufferLength, Action completed, Action<Exception> error)
|
this Stream stream, byte[] bytes, int bufferLength, Action completed, Action<Exception> error)
|
||||||
{
|
{
|
||||||
var input = new MemoryStream (bytes);
|
var input = new MemoryStream (bytes);
|
||||||
var buff = new byte[bufferLength];
|
input.CopyToAsync (
|
||||||
|
stream,
|
||||||
AsyncCallback callback = null;
|
bufferLength,
|
||||||
callback = ar => {
|
() => {
|
||||||
try {
|
|
||||||
var nread = input.EndRead (ar);
|
|
||||||
if (nread <= 0) {
|
|
||||||
if (completed != null)
|
if (completed != null)
|
||||||
completed ();
|
completed ();
|
||||||
|
|
||||||
input.Dispose ();
|
input.Dispose ();
|
||||||
return;
|
},
|
||||||
}
|
ex => {
|
||||||
|
|
||||||
stream.Write (buff, 0, nread);
|
|
||||||
input.BeginRead (buff, 0, bufferLength, callback, null);
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
input.Dispose ();
|
input.Dispose ();
|
||||||
if (error != null)
|
if (error != null)
|
||||||
error (ex);
|
error (ex);
|
||||||
}
|
});
|
||||||
};
|
|
||||||
|
|
||||||
input.BeginRead (buff, 0, bufferLength, callback, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user