Skip to content

Commit 6b75c09

Browse files
committed
fix WebSocket.cs, WsStream.cs, wsclient.cs
1 parent 6cd3f2a commit 6b75c09

26 files changed

+97
-53
lines changed

websocket-sharp.userprefs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Properties>
2-
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release_Ubuntu" ctype="Workspace" />
2+
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug_Ubuntu" ctype="Workspace" />
33
<MonoDevelop.Ide.Workbench ActiveDocument="websocket-sharp/WebSocket.cs" ctype="Workbench">
44
<Files>
5-
<File FileName="websocket-sharp/WebSocket.cs" Line="231" Column="1" />
5+
<File FileName="websocket-sharp/WebSocket.cs" Line="100" Column="1" />
66
</Files>
77
</MonoDevelop.Ide.Workbench>
88
<MonoDevelop.Ide.DebuggingService.Breakpoints>

websocket-sharp/WebSocket.cs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
*/
3131
#endregion
3232

33-
#if NOTIFY
34-
using Notifications;
35-
#endif
3633
using System;
3734
using System.Collections.Generic;
3835
using System.IO;
@@ -109,13 +106,7 @@ public string Protocol
109106
private SslStream sslStream;
110107
private IWsStream wsStream;
111108
private Thread msgThread;
112-
#if NOTIFY
113-
private Notification msgNf;
114-
public Notification MsgNf
115-
{
116-
get { return msgNf; }
117-
}
118-
#endif
109+
119110
public event EventHandler OnOpen;
120111
public event MessageEventHandler OnMessage;
121112
public event MessageEventHandler OnError;
@@ -205,11 +196,6 @@ private void close(WsState state)
205196

206197
readyState = state;
207198

208-
if (OnClose != null)
209-
{
210-
OnClose(this, EventArgs.Empty);
211-
}
212-
213199
if (wsStream != null && tcpClient.Connected)
214200
{
215201
try
@@ -228,7 +214,7 @@ private void close(WsState state)
228214
#endif
229215
}
230216
}
231-
217+
232218
if (wsStream != null)
233219
{
234220
wsStream.Dispose();
@@ -240,6 +226,14 @@ private void close(WsState state)
240226
tcpClient.Close();
241227
tcpClient = null;
242228
}
229+
230+
if (OnClose != null)
231+
{
232+
OnClose(this, EventArgs.Empty);
233+
}
234+
#if DEBUG
235+
Console.WriteLine("WS: Info @close: Exit close method.");
236+
#endif
243237
}
244238

245239
private void createConnection()
@@ -355,10 +349,6 @@ private void message()
355349
Console.WriteLine("WS: Info @message: Current thread IsBackground: {0}", Thread.CurrentThread.IsBackground);
356350
#endif
357351
string data;
358-
#if NOTIFY
359-
this.msgNf = new Notification();
360-
msgNf.AddHint("append", "allowed");
361-
#endif
362352
while (readyState == WsState.OPEN)
363353
{
364354
data = receive();
@@ -435,7 +425,7 @@ private string receive()
435425
OnError(this, e.Message);
436426
}
437427

438-
ReadyState = WsState.CLOSING;
428+
ReadyState = WsState.CLOSED;
439429
#if DEBUG
440430
Console.WriteLine("WS: Error @receive: {0}", e.Message);
441431
#endif

websocket-sharp/WsStream.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ public class WsStream<T> : IWsStream
4242

4343
public WsStream(T innerStream)
4444
{
45-
if (innerStream == null)
45+
Type streamType = typeof(T);
46+
if (streamType != typeof(NetworkStream) &&
47+
streamType != typeof(SslStream))
4648
{
47-
throw new ArgumentNullException("innerStream");
49+
throw new NotSupportedException("Unsupported Stream type: " + streamType.ToString());
4850
}
4951

50-
Type streamType = innerStream.GetType();
51-
if (streamType != typeof(NetworkStream) &&
52-
streamType != typeof(SslStream))
52+
if (innerStream == null)
5353
{
54-
throw new ArgumentException("Unsupported Stream type: " + streamType.ToString());
54+
throw new ArgumentNullException("innerStream");
5555
}
5656

5757
this.innerStream = innerStream;
0 Bytes
Binary file not shown.
-5 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
-53 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

websocket-sharp/websocket-sharp.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<DebugType>full</DebugType>
3535
<Optimize>false</Optimize>
3636
<OutputPath>bin\Debug_Ubuntu</OutputPath>
37-
<DefineConstants>DEBUG,NOTIFY</DefineConstants>
37+
<DefineConstants>DEBUG</DefineConstants>
3838
<ErrorReport>prompt</ErrorReport>
3939
<WarningLevel>4</WarningLevel>
4040
<ConsolePause>false</ConsolePause>
@@ -46,7 +46,6 @@
4646
<ErrorReport>prompt</ErrorReport>
4747
<WarningLevel>4</WarningLevel>
4848
<ConsolePause>false</ConsolePause>
49-
<DefineConstants>NOTIFY</DefineConstants>
5049
</PropertyGroup>
5150
<ItemGroup>
5251
<Reference Include="System" />

0 commit comments

Comments
 (0)