Closed andre2007 closed 4 years ago
It works fine if you use it in the loop:
import std;
import arsd.http2;
void main()
{
ubyte[] data = [0, 1, 2];
Uri uri = "ws://localhost:5000";
auto ws = new WebSocket(uri);
ws.connect();
int i = 50;
ws.onbinarymessage = (in ubyte[] message) {
i--;
assert(message == data);
if(i)
ws.send(data);
else
ws.close();
};
ws.send(data);
WebSocket.eventLoop();
}
But I see the problem now, exitEventLoop assumes it will only be used once - it sets the exit flag and then it stays set. You aren't supposed to use it this way.
so there's the fix now: https://github.com/adamdruppe/arsd/commit/c5cec0c8056bdd9ffdb38acb2df0acfd068eba61
Thanks Adam, it works now like a charm.
I have this WebSocket Echo example:
server.d
client.d
On the second iteration, client sends empty data and therefore the assertion will throw an error.