itisnajim / SocketIOUnity

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

Build error of System.Text.Json in il2cpp while using NewtonsoftJsonSerializer #30

Open wout-junius opened 2 years ago

wout-junius commented 2 years ago

So when i try to build to il2cpp i get this building error: Mono.Linker.MarkException: Error processing method: 'System.Void System.Text.Json.Nodes.JsonArray::Add(T)' in assembly: 'System.Text.Json.dll'

So this is how i use the code. As you see i set the JsonSerializer to NewtonsoftJsonSerializer as said in the Readme.

string deviceId = SystemInfo.deviceUniqueIdentifier;

            this.socket = new SocketIOUnity(uri, new SocketIOOptions
            {
                Query = new Dictionary<string, string>
                {
                    {"token", "UNITY" }
                }
                ,
                Transport = SocketIOClient.Transport.TransportProtocol.WebSocket
            });

            var jsonSerializer = new NewtonsoftJsonSerializer();

            socket.JsonSerializer = jsonSerializer;
            socket.OnConnected += async (sender, e) =>
            {
                await socket.EmitAsync("register", deviceId);
            };

            this.socket.OnUnityThread("readyDevice", onReady);

            socket.ConnectAsync();

Is it possible to get a version that is whitout System.text.json so it does not need to build that package.

itisnajim commented 1 year ago

maybe fixed https://github.com/itisnajim/SocketIOUnity/pull/37 try a newer version of SocketIOUnity and maybe update unity too, see: https://github.com/itisnajim/SocketIOUnity/issues/36