diff --git a/websocket-sharp.userprefs b/websocket-sharp.userprefs index 3d83015a..81170803 100644 --- a/websocket-sharp.userprefs +++ b/websocket-sharp.userprefs @@ -1,8 +1,8 @@  - + - + diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1f4825f3..c5d0615b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -30,9 +30,6 @@ */ #endregion -#if NOTIFY -using Notifications; -#endif using System; using System.Collections.Generic; using System.IO; @@ -109,13 +106,7 @@ namespace WebSocketSharp private SslStream sslStream; private IWsStream wsStream; private Thread msgThread; -#if NOTIFY - private Notification msgNf; - public Notification MsgNf - { - get { return msgNf; } - } -#endif + public event EventHandler OnOpen; public event MessageEventHandler OnMessage; public event MessageEventHandler OnError; @@ -205,11 +196,6 @@ namespace WebSocketSharp readyState = state; - if (OnClose != null) - { - OnClose(this, EventArgs.Empty); - } - if (wsStream != null && tcpClient.Connected) { try @@ -228,7 +214,7 @@ namespace WebSocketSharp #endif } } - + if (wsStream != null) { wsStream.Dispose(); @@ -240,6 +226,14 @@ namespace WebSocketSharp tcpClient.Close(); tcpClient = null; } + + if (OnClose != null) + { + OnClose(this, EventArgs.Empty); + } +#if DEBUG + Console.WriteLine("WS: Info @close: Exit close method."); +#endif } private void createConnection() @@ -355,10 +349,6 @@ namespace WebSocketSharp Console.WriteLine("WS: Info @message: Current thread IsBackground: {0}", Thread.CurrentThread.IsBackground); #endif string data; -#if NOTIFY - this.msgNf = new Notification(); - msgNf.AddHint("append", "allowed"); -#endif while (readyState == WsState.OPEN) { data = receive(); @@ -435,7 +425,7 @@ namespace WebSocketSharp OnError(this, e.Message); } - ReadyState = WsState.CLOSING; + ReadyState = WsState.CLOSED; #if DEBUG Console.WriteLine("WS: Error @receive: {0}", e.Message); #endif diff --git a/websocket-sharp/WsStream.cs b/websocket-sharp/WsStream.cs index 112c6ac9..4f542ad5 100644 --- a/websocket-sharp/WsStream.cs +++ b/websocket-sharp/WsStream.cs @@ -42,16 +42,16 @@ namespace WebSocketSharp public WsStream(T innerStream) { - if (innerStream == null) + Type streamType = typeof(T); + if (streamType != typeof(NetworkStream) && + streamType != typeof(SslStream)) { - throw new ArgumentNullException("innerStream"); + throw new NotSupportedException("Unsupported Stream type: " + streamType.ToString()); } - Type streamType = innerStream.GetType(); - if (streamType != typeof(NetworkStream) && - streamType != typeof(SslStream)) + if (innerStream == null) { - throw new ArgumentException("Unsupported Stream type: " + streamType.ToString()); + throw new ArgumentNullException("innerStream"); } this.innerStream = innerStream; diff --git a/websocket-sharp/bin/Debug/websocket-sharp.dll b/websocket-sharp/bin/Debug/websocket-sharp.dll index 90a5d442..da723b24 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 c01167da..574fa055 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 1cc62db8..6b20e365 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 1124d228..1f56e34e 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 3420284b..1edb6843 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 9dc706d5..8dd25380 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.csproj b/websocket-sharp/websocket-sharp.csproj index 5d91eaf0..98f67fdc 100644 --- a/websocket-sharp/websocket-sharp.csproj +++ b/websocket-sharp/websocket-sharp.csproj @@ -34,7 +34,7 @@ full false bin\Debug_Ubuntu - DEBUG,NOTIFY + DEBUG prompt 4 false @@ -46,7 +46,6 @@ prompt 4 false - NOTIFY diff --git a/websocket-sharp/websocket-sharp.pidb b/websocket-sharp/websocket-sharp.pidb index a66e68a7..a894a184 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 90a5d442..da723b24 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 c01167da..574fa055 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 3166e191..ef17fef5 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 2d0e9aaa..5812e9a2 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 1cc62db8..6b20e365 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 1124d228..1f56e34e 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 e57d8d45..3cf46de8 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 ca651f6a..b68c4d4b 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 3420284b..1edb6843 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 e5a8c5a3..bef58526 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 9dc706d5..8dd25380 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 2ed2c583..0f2099ac 100755 Binary files a/wsclient/bin/Release_Ubuntu/wsclient.exe and b/wsclient/bin/Release_Ubuntu/wsclient.exe differ diff --git a/wsclient/wsclient.cs b/wsclient/wsclient.cs index b44890de..e7b988ec 100644 --- a/wsclient/wsclient.cs +++ b/wsclient/wsclient.cs @@ -1,4 +1,4 @@ -#if LINUX +#if NOTIFY using Notifications; #endif using System; @@ -19,36 +19,24 @@ namespace Example //Do something. }; */ - ws.OnMessage += (o, e) => + ws.OnMessage += (o, s) => { -#if LINUX - #if NOTIFY - ws.MsgNf.Summary = "[WebSocket] Message"; - ws.MsgNf.Body = e; - ws.MsgNf.IconName = "notification-message-im"; - ws.MsgNf.Show(); - #else +#if NOTIFY Notification nf = new Notification("[WebSocket] Message", - e, + s, "notification-message-im"); + nf.AddHint("append", "allowed"); nf.Show(); - #endif #else - Console.WriteLine(e); + Console.WriteLine("[WebSocket] Message: {0}", s); #endif }; - ws.OnError += (o, e) => + ws.OnError += (o, s) => { -#if LINUX - Notification nf = new Notification("[WebSocket] Error", - e, - "notification-network-disconnected"); - nf.Show(); -#else - Console.WriteLine("Error: {0}", e); -#endif + Console.WriteLine("[WebSocket] Error : {0}", s); }; + /*ws.OnClose += (o, e) => { //Do something. diff --git a/wsclient/wsclient.csproj b/wsclient/wsclient.csproj index bb8f71af..313d403f 100644 --- a/wsclient/wsclient.csproj +++ b/wsclient/wsclient.csproj @@ -1 +1,68 @@ - Debug AnyCPU 9.0.21022 2.0 {52805AEC-EFB1-4F42-BB8E-3ED4E692C568} Exe WsClient wsclient v3.5 true full false bin\Debug DEBUG prompt 4 true none false bin\Release prompt 4 true true full false bin\Debug_Ubuntu DEBUG,LINUX,NOTIFY prompt 4 true none false bin\Release_Ubuntu LINUX,NOTIFY prompt 4 true notify-sharp {B357BAC7-529E-4D81-A0D2-71041B19C8DE} websocket-sharp \ No newline at end of file + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {52805AEC-EFB1-4F42-BB8E-3ED4E692C568} + Exe + WsClient + wsclient + v3.5 + + + true + full + false + bin\Debug + DEBUG + prompt + 4 + true + + + none + false + bin\Release + prompt + 4 + true + + + true + full + false + bin\Debug_Ubuntu + DEBUG,NOTIFY + prompt + 4 + true + + + 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/wsclient/wsclient.pidb b/wsclient/wsclient.pidb index 2591ccce..bc07c95e 100644 Binary files a/wsclient/wsclient.pidb and b/wsclient/wsclient.pidb differ