Closed justinduynguyen closed 2 years ago
Maybe.. if this (issue) got more votes :)
Is the issue with socket.io-client-csharp
being not compatible with WebGL or this library's implementation?
Okay I found the incompatible code. The issue was inside socket.io-client-csharp
and not the SocketIOUnity
implementation.
SocketIOClient/Transport/HttpTransport.cs
Uses the .NET library system.net.http
, which is incompatible with WebGL
Adding WebGL support should be as simple as implementing UnityWebRequest
instead of HttpClient
.
socket.io-client-csharp its not for a web project, needs a bridge so!
Another issue: socket.io-client-csharp
uses threads which aren't compatible with WebGL Unity builds yet
Well I guess rewriting socket.io-client-csharp
isn't as easy as I thought 😅
I guess you don't see any possibility of it ever being compatible?
I guess you don't see any possibility of it ever being compatible?
I'm sorry, but the socket.io-client-csharp
package is not compatible with the web. However, you can search for a web unity socket io package or create your own, check out Unity-WebGL-3D-Chat . And combine it with this package using an IF ELSE statement.
You can create two separate classes: one for web called SocketIOWebManager
and one for native called SocketIONativeManager
, and another class to communicate with one of the two depending on the current platform. You can do something similar to what is shown in the SocketManager file, where in the start method you can check the current platform and start either the SocketIOWebManager
or SocketIONativeManager
object.
I hope this helps!
hope webgl support
For those still looking for an answer, making a JS plug-in that calls socket.io seems to be the only way for now, although this solution isn't ideal.
@nekiwo Any news on this JS plug-in?
May you implement a version for WebGL or intent to do in future? I