endel / NativeWebSocket

🔌 WebSocket client for Unity - with no external dependencies (WebGL, Native, Android, iOS, UWP)
Other
1.27k stars 161 forks source link

WebGL build errors #68

Closed DaylightNebula closed 2 years ago

DaylightNebula commented 2 years ago

When I try to run a WebGL build I get the following error:

Assets\Scripts\Behavior\BehaviorClient.cs(102,16): error CS1061: 'WebSocket' does not contain a definition for 'DispatchMessageQueue' and no accessible extension method 'DispatchMessageQueue' accepting a first argument of type 'WebSocket' could be found (are you missing a using directive or an assembly reference?)

I am running Unity 2021.3.5f1

aazam476 commented 1 year ago

Did you manage to fix this, and if so, how?

pcg108 commented 5 months ago

If anyone still encounters this, it is because DispatchMessageQueue does not have a matching JavaScript definition when building for WebGL. The websocket.SendText, websocket.SendData, etc. functions are sufficient in JS when building for WebGL. They don't need to be dispatched, unlike when building for the Unity Editor.

That is why the examples have the compiler flags !UNITY_WEBGL || UNITY_EDITOR