diff --git a/websocket-sharp.userprefs b/websocket-sharp.userprefs index 0c3f8470..c8a1e31b 100644 --- a/websocket-sharp.userprefs +++ b/websocket-sharp.userprefs @@ -1,8 +1,8 @@  - + - + diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0dc29f61..8cb4c85d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -83,27 +83,6 @@ namespace WebSocketSharp return new String(secKey.ToArray()); } - public static IEnumerable IndexOf(this T[] array, T val) - { - for (int i = 0; i < array.Length; i++) - { - if (array[i].Equals(val)) - { - yield return i; - } - } - } - - public static T[] InitializeWith(this T[] array, T val) - { - for (int i = 0; i < array.Length; i++) - { - array[i] = val; - } - - return array; - } - public static Byte[] InitializeWithPrintableASCII(this Byte[] bytes, Random rand) { for (int i = 0; i < bytes.Length; i++) @@ -114,11 +93,11 @@ namespace WebSocketSharp return bytes; } - public static void NotEqualsDo(this string a, string b, Action action) + public static void NotEqualsDo(this string expected, string actual, Action action) { - if (a != b) + if (expected != actual) { - action(a, b); + action(expected, actual); } } } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f24e2b24..a0662718 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -259,7 +259,11 @@ namespace WebSocketSharp } string subProtocol = protocol != String.Empty +#if !CHALLENGE + ? String.Format("WebSocket-Protocol: {0}\r\n", protocol) +#else ? String.Format("Sec-WebSocket-Protocol: {0}\r\n", protocol) +#endif : protocol; #if !CHALLENGE string secKeys = String.Empty; @@ -325,17 +329,17 @@ namespace WebSocketSharp Console.WriteLine("{0}", s); } #endif - Action action = (a, b) => + Action action = (e, a) => { throw new IOException("Invalid handshake response: " + a); }; #if !CHALLENGE - response[0].NotEqualsDo("HTTP/1.1 101 Web Socket Protocol Handshake", action); + "HTTP/1.1 101 Web Socket Protocol Handshake".NotEqualsDo(response[0], action); #else - response[0].NotEqualsDo("HTTP/1.1 101 WebSocket Protocol Handshake", action); + "HTTP/1.1 101 WebSocket Protocol Handshake".NotEqualsDo(response[0], action); #endif - response[1].NotEqualsDo("Upgrade: WebSocket", action); - response[2].NotEqualsDo("Connection: Upgrade", action); + "Upgrade: WebSocket".NotEqualsDo(response[1], action); + "Connection: Upgrade".NotEqualsDo(response[2], action); for (int i = 3; i < response.Length; i++) { @@ -357,17 +361,15 @@ namespace WebSocketSharp string expectedResToHexStr = BitConverter.ToString(expectedRes); string actualResToHexStr = BitConverter.ToString(actualRes); - actualResToHexStr.NotEqualsDo(expectedResToHexStr, (a, b) => - { - Console.WriteLine("WS: Error @doHandshake: Invalid challenge response."); - Console.WriteLine("\texpected: {0}", b); - Console.WriteLine("\tactual : {0}", a); - throw new IOException("Invalid challenge response: " + a); - } - ); + expectedResToHexStr.NotEqualsDo(actualResToHexStr, (e, a) => + { #if DEBUG - Console.WriteLine("WS: Info @doHandshake: challenge response: {0}", actualResToHexStr); + Console.WriteLine("WS: Error @doHandshake: Invalid challenge response."); + Console.WriteLine("\texpected: {0}", e); + Console.WriteLine("\tactual : {0}", a); #endif + throw new IOException("Invalid challenge response: " + a); + }); #endif ReadyState = WsState.OPEN; } diff --git a/websocket-sharp/bin/Debug/websocket-sharp.dll b/websocket-sharp/bin/Debug/websocket-sharp.dll index 8f02ccda..2229027c 100755 Binary files a/websocket-sharp/bin/Debug/websocket-sharp.dll and b/websocket-sharp/bin/Debug/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Debug/websocket-sharp.dll.mdb b/websocket-sharp/bin/Debug/websocket-sharp.dll.mdb index 5f58012e..3c6dd935 100644 Binary files a/websocket-sharp/bin/Debug/websocket-sharp.dll.mdb and b/websocket-sharp/bin/Debug/websocket-sharp.dll.mdb differ diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll index d9f820c1..535d791c 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 247caaa1..67934106 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/bin/Release/websocket-sharp.dll b/websocket-sharp/bin/Release/websocket-sharp.dll index 1352799c..7e761146 100755 Binary files a/websocket-sharp/bin/Release/websocket-sharp.dll and b/websocket-sharp/bin/Release/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll index eacf178b..2638bb13 100755 Binary files a/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/websocket-sharp.pidb b/websocket-sharp/websocket-sharp.pidb index 20be6372..608e90c4 100644 Binary files a/websocket-sharp/websocket-sharp.pidb and b/websocket-sharp/websocket-sharp.pidb differ diff --git a/wsclient/bin/Debug/websocket-sharp.dll b/wsclient/bin/Debug/websocket-sharp.dll index 8f02ccda..2229027c 100755 Binary files a/wsclient/bin/Debug/websocket-sharp.dll and b/wsclient/bin/Debug/websocket-sharp.dll differ diff --git a/wsclient/bin/Debug/websocket-sharp.dll.mdb b/wsclient/bin/Debug/websocket-sharp.dll.mdb index 5f58012e..3c6dd935 100644 Binary files a/wsclient/bin/Debug/websocket-sharp.dll.mdb and b/wsclient/bin/Debug/websocket-sharp.dll.mdb differ diff --git a/wsclient/bin/Debug/wsclient.exe b/wsclient/bin/Debug/wsclient.exe index 58c3262d..82eb0b3c 100755 Binary files a/wsclient/bin/Debug/wsclient.exe and b/wsclient/bin/Debug/wsclient.exe differ diff --git a/wsclient/bin/Debug/wsclient.exe.mdb b/wsclient/bin/Debug/wsclient.exe.mdb index a9f0538d..7358720c 100644 Binary files a/wsclient/bin/Debug/wsclient.exe.mdb and b/wsclient/bin/Debug/wsclient.exe.mdb differ diff --git a/wsclient/bin/Debug_Ubuntu/websocket-sharp.dll b/wsclient/bin/Debug_Ubuntu/websocket-sharp.dll index d9f820c1..535d791c 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 247caaa1..67934106 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 40c55795..83240a10 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 bb02a6e0..5f1914f1 100644 Binary files a/wsclient/bin/Debug_Ubuntu/wsclient.exe.mdb and b/wsclient/bin/Debug_Ubuntu/wsclient.exe.mdb differ diff --git a/wsclient/bin/Release/websocket-sharp.dll b/wsclient/bin/Release/websocket-sharp.dll index 1352799c..7e761146 100755 Binary files a/wsclient/bin/Release/websocket-sharp.dll and b/wsclient/bin/Release/websocket-sharp.dll differ diff --git a/wsclient/bin/Release/wsclient.exe b/wsclient/bin/Release/wsclient.exe index 3a1d804e..025e5765 100755 Binary files a/wsclient/bin/Release/wsclient.exe and b/wsclient/bin/Release/wsclient.exe differ diff --git a/wsclient/bin/Release_Ubuntu/websocket-sharp.dll b/wsclient/bin/Release_Ubuntu/websocket-sharp.dll index eacf178b..2638bb13 100755 Binary files a/wsclient/bin/Release_Ubuntu/websocket-sharp.dll and b/wsclient/bin/Release_Ubuntu/websocket-sharp.dll differ diff --git a/wsclient/bin/Release_Ubuntu/wsclient.exe b/wsclient/bin/Release_Ubuntu/wsclient.exe index 33a3f3d2..0e97e1f3 100755 Binary files a/wsclient/bin/Release_Ubuntu/wsclient.exe and b/wsclient/bin/Release_Ubuntu/wsclient.exe differ