From 49a090413b9bbeab435bc2116fa73fe83a8fffbd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Jun 2019 20:26:51 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/Ext.cs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index bc93ee6a..44bfe466 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -331,29 +331,31 @@ namespace WebSocketSharp Stream destination, int bufferLength, Action completed, - Action error) + Action error + ) { var buff = new byte[bufferLength]; AsyncCallback callback = null; - callback = ar => { - try { - var nread = source.EndRead (ar); - if (nread <= 0) { - if (completed != null) - completed (); + callback = + ar => { + try { + var nread = source.EndRead (ar); + if (nread <= 0) { + if (completed != null) + completed (); - return; + return; + } + + destination.Write (buff, 0, nread); + source.BeginRead (buff, 0, bufferLength, callback, null); } - - destination.Write (buff, 0, nread); - source.BeginRead (buff, 0, bufferLength, callback, null); - } - catch (Exception ex) { - if (error != null) - error (ex); - } - }; + catch (Exception ex) { + if (error != null) + error (ex); + } + }; try { source.BeginRead (buff, 0, bufferLength, callback, null);