FluxpointDev / RevoltSharp

A C# lib for using the revolt chat API and connecting to the gateway to get events.
https://rvlt.gg/N33Rf6DE
MIT License
17 stars 3 forks source link

Proposed fix for connection hang #9

Closed Foxite closed 1 year ago

Foxite commented 1 year ago

I'm experiencing a bug where the app hangs after you call RevoltClient.StartAsync(). This only seems to happen when the app is running in debug mode.

I've done some investigating into this, and while I cannot explain why, this seems to be fixed by removing the busy wait located here. Adding a delay there fixes the problem, but well, it introduces a delay.

A better fix is to make RevoltSocketClient invoke an event to signal that it is connected. I want to add a public event RevoltEvent OnConnected to ClientEvents (RevoltEvent being a new delegate type with no parameters). Instead of busy-waiting for the websocket state to change, I want to use a TaskCompletionSource to await either this event or OnWebSocketError (returning if the former fires, and throwing if the latter fires).

What do you think?

xXBuilderBXx commented 1 year ago

Thanks for reporting the issue will have a look.

xXBuilderBXx commented 1 year ago

Hi thanks for helping out and testing the lib, good pr for the message reply too. These changes will be available in v4.0.6