Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoRoomPlugin with dataChannel #91

Open
FlavioCarnevale opened this issue Oct 21, 2022 · 9 comments
Open

VideoRoomPlugin with dataChannel #91

FlavioCarnevale opened this issue Oct 21, 2022 · 9 comments

Comments

@FlavioCarnevale
Copy link

Hi,
I am trying to configure a dataChannel in the VideoRoomPlugin but when I send a message I get nothing in the data stream.

@shivanshtalwar0
Copy link
Collaborator

I see, this was expected, i need to test it and will get back to you accordingly

@FlavioCarnevale
Copy link
Author

FlavioCarnevale commented Oct 24, 2022

Hi Shivansh,
To better explain the problem.
In my room there is a subscriber who has already created a channel and I want to listen to it.
I did so:

   videoRoom.webRTCHandle!.peerConnection!.onDataChannel = (channel) {
            log("LISTEN CHANNNEL: ${channel.label} ");
            channel.onBufferedAmountLow = (currentAmount) {
              log(currentAmount.toString(), name: "onBufferedAmountLow");
            };

      channel.onBufferedAmountChange = (currentAmount, changedAmount) {
        log(currentAmount.toString(), name: "onBufferedAmountChange");
        log(changedAmount.toString(), name: "onBufferedAmountChange");
      };

      channel.onMessage = (data) {
        log(data.text, name: "onMessage");
      };

      channel.onDataChannelState = (state) {
        log(state.name, name: "onDataChannelState");
      };

      channel.stateChangeStream.listen((state) {
        log(state.name, name: "stateChangeStream");
      });

      channel.messageStream.listen((message) {
        log(message.text, name: "messageStream");
      });
    };

Is it correct to listen to the channel in this way?

@shivanshtalwar0
Copy link
Collaborator

shivanshtalwar0 commented Oct 25, 2022

Nope this will not work because there is no data channel created on peerconnection object on webrtc handle
You need to call initDataChannel to create data channel with supported label
So check this out

Future<void> initDataChannel({RTCDataChannelInit? rtcDataChannelInit}) async {

Try calling initDataChannel then directly access peerconnection object for data channel callback although i would advise you to use helper streams to listen to events rather that directly accessing webrtcHandle?.peerconnection it is there for custom functionality only.
Try this and i believe it should work for you if it doesn't i will add data channel support in one of examples to illustrate how to use data channel with other media streams.
You can also look at setup method of textroom plugin which shows the use of initDataChannel method

@FlavioCarnevale
Copy link
Author

Hi Shivansh,
could you write an example? we can't get it to work.
Thank you

@shivanshtalwar
Copy link
Collaborator

check videocall example i have updated with datachannel illustration similar to videocall demo

edea8f8
i hope it helps you

@shivanshtalwar0
Copy link
Collaborator

Closing because of no activity you can request to reopen if you still think there are some issues.

@FlavioCarnevale
Copy link
Author

FlavioCarnevale commented Nov 2, 2022

Hi @shivanshtalwar ,
I followed your VideoCall example but I still don't get any message in the stream.
I used initDataChannel and verified that the channel has been created and is open.
I also verified that sending the message works. I put a log inside the sendData function and it is executed correctly.

I call plugin.data?.listen in joinRoom, when data is VideoRoomConfigured.
But I don't get any message.

if (data is VideoRoomConfigured) {
        log("VideoRoomConfigured", name: "configured log flavio");
        print('typed event with jsep' + event.jsep.toString());
        await plugin.handleRemoteJsep(event.jsep);

        plugin.data?.listen((message) async {
          log(message.text, name: "Message received");
        });
      }

Can you help me? Thanks

Thank you

@shivanshtalwar shivanshtalwar reopened this Nov 8, 2022
@shivanshtalwar0
Copy link
Collaborator

I have update for you, i tried setting up data channel with video room, i was able to establish data channel open connection but couldn't send anything through, till the time i investigate it further i would suggest to use textroom plugin along with videoroom plugin which seems more scalable setup to me.

@FlavioCarnevale
Copy link
Author

Hi @shivanshtalwar0,
Thank you!
Looking forward to your update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants