Closed iurii-provizio closed 4 years ago
Turns out the issue is on the side of C# event handler, possibly related to using reflection there. Closing the issue.
Reopened: turns out it wasn't bacause of reflection. Though OnMessage
handler gets invoked, the length of the message is always 0, even though jslib logs the correct length when debug is enabled there. It works fine in Unity Editor and non-WebGL builds.
Hi @iurii-provizio 👋
I couldn't reproduce the problem you've described. Here's what I've done:
cd NodeServer && npm install && npm start
(to spawn a local WebSocket server at ws://localhost:8080)NativeWebSocket/Assets/WebSocketExample/WebSocketExampleScene.unity
for the WebGL buildClient-side logs (WebGL):
Received OnMessage! (8 bytes) ��A�\s:
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
WebGLBuild.framework.js:3304 Received OnMessage! (12 bytes) hello world!
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
WebGLBuild.framework.js:3304 Received OnMessage! (8 bytes) �%�p櫙
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
WebGLBuild.framework.js:3304 Received OnMessage! (12 bytes) hello world!
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
Server-side logs:
binary received from client -> 10, 20, 30
string received from client -> 'plain text message'
binary received from client -> 10, 20, 30
string received from client -> 'plain text message'
binary received from client -> 10, 20, 30
string received from client -> 'plain text message'
binary received from client -> 10, 20, 30
string received from client -> 'plain text message'
The logs seem to be receiving binary messages on both sides. Let me know if you see a different result.
(Unity Version: 2020.1.6f1.4510 Personal)
Note: I've also now copied over the latest changes from https://github.com/colyseus/colyseus-unity3d/pull/119 to this project.
@endel Thank you a lot, the latest version (with colyseus/colyseus-unity3d#119) works fine!
Dear @endel ,
Thank you a lot for the great library. I can't make it work for WebGL builds though (at least in Unity 2020.1.4f1, I haven't tried other versions yet). The same code works just fine in non-WebGL builds. When I enable debug in the jslib, I get in the console (Google Chrome, Windows 10):
Is there anything I could check to see why I get this
___resumeException
?Btw, as suggested in Unity forums, I tried replacing
Runtime.dynCall
stuff withdynCall_viii(...)
like calls. Though works the same as theRuntime
version (f.e. successfully handles openning the connection) it still fails (the same way) to deliver the binary message with that___resumeException
.Thank you a lot!