rikulo / socket.io-client-dart

socket.io-client-dart: Dartlang port of socket.io-client https://github.com/socketio/socket.io-client
https://quire.io
MIT License
675 stars 184 forks source link

Unable to get Callback of NodeJS into Flutter #384

Closed youcci closed 4 months ago

youcci commented 4 months ago

This is my NodeJS Server Code and i want to send the callback back to Flutter According to the node js socket io callback is a valid function: https://socket.io/docs/v4/emitting-events/#acknowledgements

Is there an implementation in Flutter to handle it?

    socket.on('createRoom', async (callback) => {
        console.log('Create Room triggered')
        if (router === undefined) {
            router = await worker.createRouter({ mediaCodecs })
            console.log('Router Created: ', router.id)
        }

        getRtpCapabilities(callback)
     })

    const getRtpCapabilities = (callback) => {
        const rtpCapabilities = router.rtpCapabilities
        callback({rtpCapabilities})
    }

This is my Flutter Code. i just want to test getting Data from the callback


socket.emitWithAck(
      'createRoom',
      {},
      ack: (data) {
        print(data);
      },
    );

But when doing so i get an error on my server


callback({ rtpCapabilities });
        ^

TypeError: callback is not a function

Can someone help?

mohammedsalem97 commented 5 days ago

it faced me too!