diff --git a/websocket-sharp.userprefs b/websocket-sharp.userprefs index c8a1e31b..40b366ad 100644 --- a/websocket-sharp.userprefs +++ b/websocket-sharp.userprefs @@ -2,7 +2,7 @@ - + diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 8cb4c85d..54934a29 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -34,9 +34,9 @@ namespace WebSocketSharp { public static class Ext { - public static bool EqualsWithSaveTo(this int asbyte, char c, List dist) + public static bool EqualsWithSaveTo(this int asByte, char c, List dist) { - byte b = (byte)asbyte; + byte b = (byte)asByte; dist.Add(b); return b == Convert.ToByte(c); } @@ -68,17 +68,17 @@ namespace WebSocketSharp List secKey = new List(mKey.ToString().ToCharArray()); int i; - for (int n = 0; n < ascii; n++) + ascii.Times( () => { i = rand.Next(secKey.Count + 1); secKey.Insert(i, rand.GeneratePrintableASCIIwithoutSPandNum()); - } + } ); - for (int n = 0; n < space; n++) + space.Times( () => { i = rand.Next(1, secKey.Count); secKey.Insert(i, ' '); - } + } ); return new String(secKey.ToArray()); } @@ -93,11 +93,19 @@ namespace WebSocketSharp return bytes; } - public static void NotEqualsDo(this string expected, string actual, Action action) + public static void NotEqualsDo(this string expected, string actual, Action act) { if (expected != actual) { - action(expected, actual); + act(expected, actual); + } + } + + public static void Times(this int n, Action act) + { + for (int i = 0; i < n; i++) + { + act(); } } } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a0662718..f92f94a8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -329,17 +329,17 @@ namespace WebSocketSharp Console.WriteLine("{0}", s); } #endif - Action action = (e, a) => + Action act = (e, a) => { throw new IOException("Invalid handshake response: " + a); }; #if !CHALLENGE - "HTTP/1.1 101 Web Socket Protocol Handshake".NotEqualsDo(response[0], action); + "HTTP/1.1 101 Web Socket Protocol Handshake".NotEqualsDo(response[0], act); #else - "HTTP/1.1 101 WebSocket Protocol Handshake".NotEqualsDo(response[0], action); + "HTTP/1.1 101 WebSocket Protocol Handshake".NotEqualsDo(response[0], act); #endif - "Upgrade: WebSocket".NotEqualsDo(response[1], action); - "Connection: Upgrade".NotEqualsDo(response[2], action); + "Upgrade: WebSocket".NotEqualsDo(response[1], act); + "Connection: Upgrade".NotEqualsDo(response[2], act); for (int i = 3; i < response.Length; i++) { diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll index 8ca4b9b0..bd2afbcb 100755 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 87228ded..7d459892 100644 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/websocket-sharp/websocket-sharp.pidb b/websocket-sharp/websocket-sharp.pidb index 46ed580f..42039041 100644 Binary files a/websocket-sharp/websocket-sharp.pidb and b/websocket-sharp/websocket-sharp.pidb differ diff --git a/wsclient/bin/Debug_Ubuntu/websocket-sharp.dll b/wsclient/bin/Debug_Ubuntu/websocket-sharp.dll index 8ca4b9b0..bd2afbcb 100755 Binary files a/wsclient/bin/Debug_Ubuntu/websocket-sharp.dll and b/wsclient/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/wsclient/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/wsclient/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 87228ded..7d459892 100644 Binary files a/wsclient/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/wsclient/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/wsclient/bin/Debug_Ubuntu/wsclient.exe b/wsclient/bin/Debug_Ubuntu/wsclient.exe index 94a42eb1..d3f70e3f 100755 Binary files a/wsclient/bin/Debug_Ubuntu/wsclient.exe and b/wsclient/bin/Debug_Ubuntu/wsclient.exe differ diff --git a/wsclient/bin/Debug_Ubuntu/wsclient.exe.mdb b/wsclient/bin/Debug_Ubuntu/wsclient.exe.mdb index d0507e1c..e878c1b1 100644 Binary files a/wsclient/bin/Debug_Ubuntu/wsclient.exe.mdb and b/wsclient/bin/Debug_Ubuntu/wsclient.exe.mdb differ