Closed ProbablePrime closed 2 years ago
You must subscribe to the Connected and Disconnected events after opening a connection. Do not rely on IsConnected before receiving a Connected event
Is that not a bug then?
Should not the IsConnected boolean reflect the accurate status?
IsConnected is effectively useless.
If you don't wait for the Connected event then yes, you are relying on just the Websocket connection without the actual authentication. This was a change introduced in Websocket v5 (previously connection already passed the authentication). I don't consider it a bug since IsConnected always checked the Websocket connection and not whether or not you can start sending commands. To send commands you MUST wait for a connected event. I cab update the readme to explain the correct connection flow.
Ok, thank you
That's all well and all, using the events is the better approach, but then this should be changed.
Issue Type
Describe the bug
IsConnected
currently only reflects the status of the internal WebSocket of this client. It doesn't reflect if a connection has actually been made and setup correctly.If requests to OBS that require identification are made before the connection is fully identified OBS will disconnect you with an error reason of basically "Unidentified".
To get around this, I have to maintain my own separate boolean which gets flipped in response to the actual Connected/Disconnected events which this client outputs. While this works, It is confusing.
To Reproduce
IsConnected
is set to true repeatedlyIsConnected
gets set to true, immediately try and make a request such asGetStats
Expected behavior I expect
IsConnected
to mirror the state reflected by the connected and disconnected events of this client. Right now there are two definitions of connected and they both mean different things:I expect these two meanings to be identical.
Screenshots If applicable, add screenshots to help explain your problem.
Versions OBS WebSocket Dotnet (this library) Version: Latest, you can just see this in the source code: https://github.com/BarRaider/obs-websocket-dotnet/blob/master/obs-websocket-dotnet/OBSWebsocket.cs#L58
Additional context In slightly brash terms, I consider the IsConnected boolean to be lieing.