[Modify] Polish it
This commit is contained in:
		| @@ -142,24 +142,22 @@ namespace WebSocketSharp | |||||||
|  |  | ||||||
|     private static byte[] readBytes (this Stream stream, byte[] buffer, int offset, int count) |     private static byte[] readBytes (this Stream stream, byte[] buffer, int offset, int count) | ||||||
|     { |     { | ||||||
|       var cnt = 0; |       var nread = 0; | ||||||
|       try { |       try { | ||||||
|         cnt = stream.Read (buffer, offset, count); |         while (true) { | ||||||
|         if (cnt < 1) |           nread = stream.Read (buffer, offset, count); | ||||||
|           return buffer.SubArray (0, offset); |           if (nread == 0 || nread == count) | ||||||
|  |  | ||||||
|         while (cnt < count) { |  | ||||||
|           var nread = stream.Read (buffer, offset + cnt, count - cnt); |  | ||||||
|           if (nread < 1) |  | ||||||
|             break; |             break; | ||||||
|  |  | ||||||
|           cnt += nread; |           offset += nread; | ||||||
|  |           count -= nread; | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|       catch { |       catch { | ||||||
|  |         nread = 0; | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       return cnt < count ? buffer.SubArray (0, offset + cnt) : buffer; |       return buffer.SubArray (0, offset + nread); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static void readBytesAsync ( |     private static void readBytesAsync ( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user