Open divillysausages opened 3 years ago
You'd also need to remove the finally
block from Connect()
, otherwise the socket will disconnect immediately
@divillysausages and what is the solution for WEBGL? because this works on !UNITY_WEBGL && UNITY_EDITOR only
@RealApolo It's been a while since I looked at this, but IIRC, WEBGL either didn't have the problem, or didn't need the fix
Current
Receive()
is called at the end ofConnect()
. This means that if you ever want to await theConnect()
call (so that you move on when it's connected), it won't actually return until the socket is disconnected. Moving it to it's ownListen()
method would allow for that.Something like:
This lets you handle the websocket connection like so:
Then actually using it in a method becomes much simpler. You can connect with something like:
As an added benefit, you don't need special handling for WebGL and nothing blocks unless it should