itisnajim / SocketIOUnity

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

Socket.EmitAsync() Not working on Android Oculus Build #60

Closed toly-ua closed 1 year ago

toly-ua commented 1 year ago

I am having an issue where the socket.EmitAsync functions do not appear to be working in a Release build on Oculus. This issue only occurs in the build and everything works as expected in the Editor and Oculus Link, only build causes this issue. I am getting the inital connection established but nothing else seems to trigger as expected.

Trying to resolve the issue so far I have

Unity Version - 2021.3.14 Socket.io Version - 4.6.1 UnitySocketIO - 1.1.4


    public void Setup()
    {
        streamCamera.gameObject.SetActive(true);
        StartCoroutine(WebRTC.Update());

        StartCoroutine(SetLocalStream());
        socket = new SocketIO(ServerURL);
        socket.OnConnected += (sender, e) =>
        {
            Debug.Log("WebRTC: WebSocket Connection Established: " + socket.Id);

        };
        socket.ConnectAsync();
    }

    [ContextMenu("JoinCall")]
    public void JoinCall()
    {
        Debug.Log("WebRTC: Joining Call");
        if (socket == null) return;
        sourceImage.texture = streamCamera.targetTexture;
        sourceImage.color = Color.white;

        Debug.Log("WebRTC: Before emit Joining Call");

        socket.EmitAsync("join", roomName);
    }
itisnajim commented 1 year ago

did u've tried ? : https://github.com/itisnajim/SocketIOUnity/issues/55 https://github.com/itisnajim/SocketIOUnity/issues/45 https://github.com/itisnajim/SocketIOUnity/issues/32 https://github.com/itisnajim/SocketIOUnity/issues/22 https://github.com/itisnajim/SocketIOUnity/issues/12

toly-ua commented 1 year ago

We've added JsonSerializer and it fixed the issue

socket.JsonSerializer = new NewtonsoftJsonSerializer();

 public async void JoinCall()
 {
        Debug.Log("Joining Call");
        if (socket == null) return;

        await socket.ConnectAsync();
        await socket.EmitAsync("join", roomName);
 }