itisnajim / SocketIOUnity

A Wrapper for socket.io-client-csharp to work with Unity.
MIT License
406 stars 69 forks source link

Not work with IL2CPP #59

Closed NguyenAnhDuc closed 1 year ago

NguyenAnhDuc commented 1 year ago

The library does not work with IL2CPP, only works with Mono. Another person has also encountered a similar issue as me: https://stackoverflow.com/questions/59029987/how-to-prevent-code-stripping-with-il2cpp

To summarize: For Android, it only works when using Mono, not when using IL2CPP. For Apple/iOS, since they only accept IL2CPP, I see no way to make it work.

itisnajim commented 1 year ago

https://github.com/itisnajim/SocketIOUnity/issues/45#issuecomment-1482591619

https://github.com/itisnajim/SocketIOUnity/issues/26#issuecomment-1210465978

NguyenAnhDuc commented 1 year ago

Have try change setting the build settings in unity in IL2CPP from Faster runtime to Faster (Smaller) builds but still not work

devalvitec commented 1 year ago

I have developed a game with this package. it runs fine in the editor but it is not connecting from Android devices to the server (simulators/mobile devices). can anyone let me know the reason for this? is there any solution to this problem?

itisnajim commented 1 year ago

try these: https://github.com/itisnajim/SocketIOUnity/issues/60

timbotimbo commented 1 year ago

For me socket connections worked with IL2CPP, but Emits from mobile were broken. This was caused by IL2CPP breaking the JSON serializer that is used by default. Simply switching to the Newtonsoft option (that's already included) made it work on Android and iOS.

using SocketIOClient.Newtonsoft.Json;

socket = new SocketIOUnity( ... );
socket.JsonSerializer = new NewtonsoftJsonSerializer();
devalvitec commented 1 year ago

Thanks for the reply but still it's not working, is there any other setting needs to change to make it work?

ArthurVanRemoortel commented 10 months ago

@devalvitec Having the same issue. Did you find a solution?

devalvitec commented 10 months ago

Yes I got the solution @ArthurVanRemoortel , I just need to update the Unity version to 2022.3.10f1 and it works, also for 2021 version change the IL2CPP Code Generation to faster (smaller) build and then try. It should work. image