diff --git a/websocket-sharp.sln b/websocket-sharp.sln
index c2c1c208..82aee85e 100644
--- a/websocket-sharp.sln
+++ b/websocket-sharp.sln
@@ -5,6 +5,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "websocket-sharp", "websocke
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wsclient", "wsclient\wsclient.csproj", "{52805AEC-EFB1-4F42-BB8E-3ED4E692C568}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wsclient1", "wsclient1\wsclient1.csproj", "{B0B609B7-A81C-46B0-A9B8-82E9716D355B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,14 @@ Global
{52805AEC-EFB1-4F42-BB8E-3ED4E692C568}.Release_Ubuntu|Any CPU.Build.0 = Release_Ubuntu|Any CPU
{52805AEC-EFB1-4F42-BB8E-3ED4E692C568}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52805AEC-EFB1-4F42-BB8E-3ED4E692C568}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B0B609B7-A81C-46B0-A9B8-82E9716D355B}.Debug_Ubuntu|Any CPU.ActiveCfg = Debug_Ubuntu|Any CPU
+ {B0B609B7-A81C-46B0-A9B8-82E9716D355B}.Debug_Ubuntu|Any CPU.Build.0 = Debug_Ubuntu|Any CPU
+ {B0B609B7-A81C-46B0-A9B8-82E9716D355B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B0B609B7-A81C-46B0-A9B8-82E9716D355B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B0B609B7-A81C-46B0-A9B8-82E9716D355B}.Release_Ubuntu|Any CPU.ActiveCfg = Release_Ubuntu|Any CPU
+ {B0B609B7-A81C-46B0-A9B8-82E9716D355B}.Release_Ubuntu|Any CPU.Build.0 = Release_Ubuntu|Any CPU
+ {B0B609B7-A81C-46B0-A9B8-82E9716D355B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B0B609B7-A81C-46B0-A9B8-82E9716D355B}.Release|Any CPU.Build.0 = Release|Any CPU
{B357BAC7-529E-4D81-A0D2-71041B19C8DE}.Debug_Ubuntu|Any CPU.ActiveCfg = Debug_Ubuntu|Any CPU
{B357BAC7-529E-4D81-A0D2-71041B19C8DE}.Debug_Ubuntu|Any CPU.Build.0 = Debug_Ubuntu|Any CPU
{B357BAC7-529E-4D81-A0D2-71041B19C8DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
diff --git a/websocket-sharp.userprefs b/websocket-sharp.userprefs
index 5833fa07..4075dc26 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 54934a29..f0c318a7 100644
--- a/websocket-sharp/Ext.cs
+++ b/websocket-sharp/Ext.cs
@@ -93,7 +93,7 @@ namespace WebSocketSharp
return bytes;
}
- public static void NotEqualsDo(this string expected, string actual, Action act)
+ public static void AreNotEqualDo(this string expected, string actual, Action act)
{
if (expected != actual)
{
diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs
index f3fcf81d..6b89aed0 100644
--- a/websocket-sharp/WebSocket.cs
+++ b/websocket-sharp/WebSocket.cs
@@ -129,8 +129,41 @@ namespace WebSocketSharp
this.protocol = protocol;
}
+ public WebSocket(
+ string url,
+ EventHandler onOpen,
+ MessageEventHandler onMessage,
+ MessageEventHandler onError,
+ EventHandler onClose)
+ : this(url, String.Empty, onOpen, onMessage, onError, onClose)
+ {
+ }
+
+ public WebSocket(
+ string url,
+ string protocol,
+ EventHandler onOpen,
+ MessageEventHandler onMessage,
+ MessageEventHandler onError,
+ EventHandler onClose)
+ : this(url, protocol)
+ {
+ this.OnOpen += onOpen;
+ this.OnMessage += onMessage;
+ this.OnError += onError;
+ this.OnClose += onClose;
+
+ Connect();
+ }
+
public void Connect()
{
+ if (readyState == WsState.OPEN)
+ {
+ Console.WriteLine("WS: Info @Connect: Connection is already established.");
+ return;
+ }
+
createConnection();
doHandshake();
@@ -286,9 +319,10 @@ namespace WebSocketSharp
{
throw new IOException("Invalid handshake response: " + a);
};
- "HTTP/1.1 101 WebSocket Protocol Handshake".NotEqualsDo(response[0], act);
- "Upgrade: WebSocket".NotEqualsDo(response[1], act);
- "Connection: Upgrade".NotEqualsDo(response[2], act);
+
+ "HTTP/1.1 101 WebSocket Protocol Handshake".AreNotEqualDo(response[0], act);
+ "Upgrade: WebSocket".AreNotEqualDo(response[1], act);
+ "Connection: Upgrade".AreNotEqualDo(response[2], act);
for (int i = 3; i < response.Length; i++)
{
@@ -305,13 +339,13 @@ namespace WebSocketSharp
string expectedResToHexStr = BitConverter.ToString(expectedRes);
string actualResToHexStr = BitConverter.ToString(actualRes);
- expectedResToHexStr.NotEqualsDo(actualResToHexStr, (e, a) =>
+ expectedResToHexStr.AreNotEqualDo(actualResToHexStr, (e, a) =>
{
- #if DEBUG
+#if DEBUG
Console.WriteLine("WS: Error @doHandshake: Invalid challenge response.");
Console.WriteLine("\texpected: {0}", e);
Console.WriteLine("\tactual : {0}", a);
- #endif
+#endif
throw new IOException("Invalid challenge response: " + a);
});
diff --git a/websocket-sharp/bin/Debug/websocket-sharp.dll b/websocket-sharp/bin/Debug/websocket-sharp.dll
index 05920489..fc03a9e0 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 48d46df4..668c5ebe 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 3f102feb..bdb1f5a0 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 d5b7c2db..abc32c45 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 c8c97066..ff31194c 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 549a498b..5045e66a 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 17ce51c8..b5e98b78 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 05920489..fc03a9e0 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 48d46df4..668c5ebe 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 8417f482..3d83163f 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 2e18ba06..ece27c38 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 3f102feb..bdb1f5a0 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 d5b7c2db..abc32c45 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 da625a5e..7b6de2bd 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 d51fa738..63ac6cc4 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 c8c97066..ff31194c 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 a115807a..203b1253 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 549a498b..5045e66a 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 f51cdac0..4f7bf6a9 100755
Binary files a/wsclient/bin/Release_Ubuntu/wsclient.exe and b/wsclient/bin/Release_Ubuntu/wsclient.exe differ
diff --git a/wsclient/wsclient.pidb b/wsclient/wsclient.pidb
index 214097e1..77dd8daa 100644
Binary files a/wsclient/wsclient.pidb and b/wsclient/wsclient.pidb differ
diff --git a/wsclient1/AssemblyInfo.cs b/wsclient1/AssemblyInfo.cs
new file mode 100644
index 00000000..5d7a651f
--- /dev/null
+++ b/wsclient1/AssemblyInfo.cs
@@ -0,0 +1,27 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("wsclient1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
diff --git a/wsclient1/bin/Debug/websocket-sharp.dll b/wsclient1/bin/Debug/websocket-sharp.dll
new file mode 100755
index 00000000..fc03a9e0
Binary files /dev/null and b/wsclient1/bin/Debug/websocket-sharp.dll differ
diff --git a/wsclient1/bin/Debug/websocket-sharp.dll.mdb b/wsclient1/bin/Debug/websocket-sharp.dll.mdb
new file mode 100644
index 00000000..668c5ebe
Binary files /dev/null and b/wsclient1/bin/Debug/websocket-sharp.dll.mdb differ
diff --git a/wsclient1/bin/Debug/wsclient1.exe b/wsclient1/bin/Debug/wsclient1.exe
new file mode 100755
index 00000000..cf4e6f0d
Binary files /dev/null and b/wsclient1/bin/Debug/wsclient1.exe differ
diff --git a/wsclient1/bin/Debug/wsclient1.exe.mdb b/wsclient1/bin/Debug/wsclient1.exe.mdb
new file mode 100644
index 00000000..72b32853
Binary files /dev/null and b/wsclient1/bin/Debug/wsclient1.exe.mdb differ
diff --git a/wsclient1/bin/Debug_Ubuntu/websocket-sharp.dll b/wsclient1/bin/Debug_Ubuntu/websocket-sharp.dll
new file mode 100755
index 00000000..bdb1f5a0
Binary files /dev/null and b/wsclient1/bin/Debug_Ubuntu/websocket-sharp.dll differ
diff --git a/wsclient1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/wsclient1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb
new file mode 100644
index 00000000..abc32c45
Binary files /dev/null and b/wsclient1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ
diff --git a/wsclient1/bin/Debug_Ubuntu/wsclient1.exe b/wsclient1/bin/Debug_Ubuntu/wsclient1.exe
new file mode 100755
index 00000000..e660a28e
Binary files /dev/null and b/wsclient1/bin/Debug_Ubuntu/wsclient1.exe differ
diff --git a/wsclient1/bin/Debug_Ubuntu/wsclient1.exe.mdb b/wsclient1/bin/Debug_Ubuntu/wsclient1.exe.mdb
new file mode 100644
index 00000000..90b7ae43
Binary files /dev/null and b/wsclient1/bin/Debug_Ubuntu/wsclient1.exe.mdb differ
diff --git a/wsclient1/bin/Release/websocket-sharp.dll b/wsclient1/bin/Release/websocket-sharp.dll
new file mode 100755
index 00000000..ff31194c
Binary files /dev/null and b/wsclient1/bin/Release/websocket-sharp.dll differ
diff --git a/wsclient1/bin/Release/wsclient1.exe b/wsclient1/bin/Release/wsclient1.exe
new file mode 100755
index 00000000..038b40d2
Binary files /dev/null and b/wsclient1/bin/Release/wsclient1.exe differ
diff --git a/wsclient1/bin/Release_Ubuntu/websocket-sharp.dll b/wsclient1/bin/Release_Ubuntu/websocket-sharp.dll
new file mode 100755
index 00000000..5045e66a
Binary files /dev/null and b/wsclient1/bin/Release_Ubuntu/websocket-sharp.dll differ
diff --git a/wsclient1/bin/Release_Ubuntu/wsclient1.exe b/wsclient1/bin/Release_Ubuntu/wsclient1.exe
new file mode 100755
index 00000000..bb2e5fe2
Binary files /dev/null and b/wsclient1/bin/Release_Ubuntu/wsclient1.exe differ
diff --git a/wsclient1/wsclient1.cs b/wsclient1/wsclient1.cs
new file mode 100644
index 00000000..edc78115
--- /dev/null
+++ b/wsclient1/wsclient1.cs
@@ -0,0 +1,65 @@
+#if NOTIFY
+using Notifications;
+#endif
+using System;
+using System.Threading;
+using WebSocketSharp;
+
+namespace Example
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ EventHandler onOpen = (o, e) =>
+ {
+ Console.WriteLine("[WebSocket] Opened.");
+ };
+
+ MessageEventHandler onMessage = (o, s) =>
+ {
+#if NOTIFY
+ Notification nf = new Notification("[WebSocket] Message",
+ s,
+ "notification-message-im");
+ nf.AddHint("append", "allowed");
+ nf.Show();
+#else
+ Console.WriteLine("[WebSocket] Message: {0}", s);
+#endif
+ };
+
+ MessageEventHandler onError = (o, s) =>
+ {
+ Console.WriteLine("[WebSocket] Error : {0}", s);
+ };
+
+ EventHandler onClose = (o, e) =>
+ {
+ Console.WriteLine("[WebSocket] Closed.");
+ };
+
+ //using (WebSocket ws = new WebSocket("ws://localhost:8000/", onOpen, onMessage, onError, onClose))
+ using (WebSocket ws = new WebSocket("ws://localhost:8000/", "chat", onOpen, onMessage, onError, onClose))
+ {
+ Thread.Sleep(500);
+ Console.WriteLine("\nType \"exit\" to exit.\n");
+
+ string data;
+ while (true)
+ {
+ Thread.Sleep(500);
+
+ Console.Write("> ");
+ data = Console.ReadLine();
+ if (data == "exit")
+ {
+ break;
+ }
+
+ ws.Send(data);
+ }
+ }
+ }
+ }
+}
diff --git a/wsclient1/wsclient1.csproj b/wsclient1/wsclient1.csproj
new file mode 100644
index 00000000..ea2c1449
--- /dev/null
+++ b/wsclient1/wsclient1.csproj
@@ -0,0 +1,68 @@
+
+
+
+ Debug
+ AnyCPU
+ 9.0.21022
+ 2.0
+ {B0B609B7-A81C-46B0-A9B8-82E9716D355B}
+ Exe
+ wsclient1
+ wsclient1
+ v3.5
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG
+ prompt
+ 4
+ true
+
+
+ none
+ false
+ bin\Release
+ prompt
+ 4
+ true
+
+
+ full
+ false
+ bin\Debug_Ubuntu
+ prompt
+ 4
+ true
+ true
+ DEBUG,NOTIFY
+
+
+ none
+ false
+ bin\Release_Ubuntu
+ NOTIFY
+ prompt
+ 4
+ true
+
+
+
+
+ notify-sharp
+
+
+
+
+
+
+
+
+ {B357BAC7-529E-4D81-A0D2-71041B19C8DE}
+ websocket-sharp
+
+
+
+
\ No newline at end of file
diff --git a/wsclient1/wsclient1.pidb b/wsclient1/wsclient1.pidb
new file mode 100644
index 00000000..21166ed0
Binary files /dev/null and b/wsclient1/wsclient1.pidb differ