|
|
|
@ -140,45 +140,6 @@ namespace WebSocketSharp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void readBytesAsync (
|
|
|
|
|
|
|
|
this Stream stream,
|
|
|
|
|
|
|
|
byte[] buffer,
|
|
|
|
|
|
|
|
int offset,
|
|
|
|
|
|
|
|
int count,
|
|
|
|
|
|
|
|
Action<byte[]> completed,
|
|
|
|
|
|
|
|
Action<Exception> error)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
AsyncCallback callback = null;
|
|
|
|
|
|
|
|
callback = ar => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
var nread = stream.EndRead (ar);
|
|
|
|
|
|
|
|
if (nread == 0 || nread == count) {
|
|
|
|
|
|
|
|
if (completed != null)
|
|
|
|
|
|
|
|
completed (buffer.SubArray (0, offset + nread));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
offset += nread;
|
|
|
|
|
|
|
|
count -= nread;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stream.BeginRead (buffer, offset, count, callback, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
|
|
|
if (error != null)
|
|
|
|
|
|
|
|
error (ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
stream.BeginRead (buffer, offset, count, callback, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
|
|
|
if (error != null)
|
|
|
|
|
|
|
|
error (ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void times (this ulong n, Action action)
|
|
|
|
private static void times (this ulong n, Action action)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (ulong i = 0; i < n; i++)
|
|
|
|
for (ulong i = 0; i < n; i++)
|
|
|
|
@ -668,14 +629,15 @@ namespace WebSocketSharp
|
|
|
|
if (len < bufferLength)
|
|
|
|
if (len < bufferLength)
|
|
|
|
bufferLength = (int) len;
|
|
|
|
bufferLength = (int) len;
|
|
|
|
|
|
|
|
|
|
|
|
stream.readBytesAsync (
|
|
|
|
stream.BeginRead (
|
|
|
|
buff,
|
|
|
|
buff,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
bufferLength,
|
|
|
|
bufferLength,
|
|
|
|
bytes => {
|
|
|
|
ar => {
|
|
|
|
var nread = bytes.Length;
|
|
|
|
try {
|
|
|
|
|
|
|
|
var nread = stream.EndRead (ar);
|
|
|
|
if (nread > 0)
|
|
|
|
if (nread > 0)
|
|
|
|
dest.Write (bytes, 0, nread);
|
|
|
|
dest.Write (buff, 0, nread);
|
|
|
|
|
|
|
|
|
|
|
|
if (nread == 0 || nread == len) {
|
|
|
|
if (nread == 0 || nread == len) {
|
|
|
|
if (completed != null) {
|
|
|
|
if (completed != null) {
|
|
|
|
@ -688,16 +650,25 @@ namespace WebSocketSharp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
read (len - nread);
|
|
|
|
read (len - nread);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
ex => {
|
|
|
|
catch (Exception ex) {
|
|
|
|
dest.Dispose ();
|
|
|
|
dest.Dispose ();
|
|
|
|
if (error != null)
|
|
|
|
if (error != null)
|
|
|
|
error (ex);
|
|
|
|
error (ex);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
null);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
read (length);
|
|
|
|
read (length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
|
|
|
dest.Dispose ();
|
|
|
|
|
|
|
|
if (error != null)
|
|
|
|
|
|
|
|
error (ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal static string RemovePrefix (this string value, params string[] prefixes)
|
|
|
|
internal static string RemovePrefix (this string value, params string[] prefixes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|