Fix for issue #5

This commit is contained in:
sta
2012-08-18 02:17:12 +09:00
parent 4613831582
commit ff94d551ff
47 changed files with 20 additions and 18 deletions

View File

@@ -766,6 +766,21 @@ namespace WebSocketSharp
}
}
private void messageLoopCallback(IAsyncResult ar)
{
Action messageInvoker = (Action)ar.AsyncState;
messageInvoker.EndInvoke(ar);
if (_readyState == WsState.OPEN)
{
messageInvoker.BeginInvoke(messageLoopCallback, messageInvoker);
}
else
{
_autoEvent.Set();
}
}
private void pong(PayloadData data)
{
var frame = createFrame(Fin.FINAL, Opcode.PONG, data);
@@ -1090,27 +1105,14 @@ namespace WebSocketSharp
else
{
_autoEvent = new AutoResetEvent(false);
Action act = () =>
Action messageInvoker = () =>
{
if (_readyState == WsState.OPEN)
{
message();
}
};
AsyncCallback callback = (ar) =>
{
act.EndInvoke(ar);
if (_readyState == WsState.OPEN)
{
act.BeginInvoke(callback, null);
}
else
{
_autoEvent.Set();
}
};
act.BeginInvoke(callback, null);
messageInvoker.BeginInvoke(messageLoopCallback, messageInvoker);
}
}

Binary file not shown.