Skip to content

Commit 6cd3f2a

Browse files
committed
fix WebSocket.cs
1 parent e9d591b commit 6cd3f2a

21 files changed

+17
-19
lines changed

websocket-sharp.userprefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release_Ubuntu" ctype="Workspace" />
33
<MonoDevelop.Ide.Workbench ActiveDocument="websocket-sharp/WebSocket.cs" ctype="Workbench">
44
<Files>
5-
<File FileName="websocket-sharp/WebSocket.cs" Line="5" Column="54" />
5+
<File FileName="websocket-sharp/WebSocket.cs" Line="231" Column="1" />
66
</Files>
77
</MonoDevelop.Ide.Workbench>
88
<MonoDevelop.Ide.DebuggingService.Breakpoints>

websocket-sharp/WebSocket.cs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,15 @@ private void close(WsState state)
219219
}
220220
catch (Exception e)
221221
{
222+
if (OnError != null)
223+
{
224+
OnError(this, e.Message);
225+
}
222226
#if DEBUG
223227
Console.WriteLine("WS: Error @close: {0}", e.Message);
224228
#endif
225229
}
226230
}
227-
228-
if (!(Thread.CurrentThread.IsBackground) &&
229-
msgThread != null && msgThread.IsAlive)
230-
{
231-
msgThread.Join();
232-
}
233231

234232
if (wsStream != null)
235233
{
@@ -363,14 +361,11 @@ private void message()
363361
#endif
364362
while (readyState == WsState.OPEN)
365363
{
366-
while (readyState == WsState.OPEN && netStream.DataAvailable)
367-
{
368-
data = receive();
364+
data = receive();
369365

370-
if (OnMessage != null && data != null)
371-
{
372-
OnMessage(this, data);
373-
}
366+
if (OnMessage != null && data != null)
367+
{
368+
OnMessage(this, data);
374369
}
375370
}
376371
#if DEBUG
@@ -433,15 +428,18 @@ private string receive()
433428
}
434429
catch (Exception e)
435430
{
436-
if (OnError != null)
431+
if (readyState == WsState.OPEN)
437432
{
438-
OnError(this, e.Message);
439-
}
433+
if (OnError != null)
434+
{
435+
OnError(this, e.Message);
436+
}
440437

441-
ReadyState = WsState.CLOSED;
438+
ReadyState = WsState.CLOSING;
442439
#if DEBUG
443-
Console.WriteLine("WS: Error @receive: {0}", e.Message);
440+
Console.WriteLine("WS: Error @receive: {0}", e.Message);
444441
#endif
442+
}
445443
}
446444

447445
return null;
0 Bytes
Binary file not shown.
-10 Bytes
Binary file not shown.
-512 Bytes
Binary file not shown.
-11 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
-512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)