[Modify] Polish it
This commit is contained in:
parent
47e53eda0b
commit
49a090413b
@ -331,29 +331,31 @@ namespace WebSocketSharp
|
|||||||
Stream destination,
|
Stream destination,
|
||||||
int bufferLength,
|
int bufferLength,
|
||||||
Action completed,
|
Action completed,
|
||||||
Action<Exception> error)
|
Action<Exception> error
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var buff = new byte[bufferLength];
|
var buff = new byte[bufferLength];
|
||||||
|
|
||||||
AsyncCallback callback = null;
|
AsyncCallback callback = null;
|
||||||
callback = ar => {
|
callback =
|
||||||
try {
|
ar => {
|
||||||
var nread = source.EndRead (ar);
|
try {
|
||||||
if (nread <= 0) {
|
var nread = source.EndRead (ar);
|
||||||
if (completed != null)
|
if (nread <= 0) {
|
||||||
completed ();
|
if (completed != null)
|
||||||
|
completed ();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
destination.Write (buff, 0, nread);
|
||||||
|
source.BeginRead (buff, 0, bufferLength, callback, null);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
destination.Write (buff, 0, nread);
|
if (error != null)
|
||||||
source.BeginRead (buff, 0, bufferLength, callback, null);
|
error (ex);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
};
|
||||||
if (error != null)
|
|
||||||
error (ex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
source.BeginRead (buff, 0, bufferLength, callback, null);
|
source.BeginRead (buff, 0, bufferLength, callback, null);
|
||||||
|
Loading…
Reference in New Issue
Block a user