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

Cannot create multiple DataStreams from one PeerConnection #4

Open
eras opened this issue Dec 29, 2022 · 1 comment
Open

Cannot create multiple DataStreams from one PeerConnection #4

eras opened this issue Dec 29, 2022 · 1 comment

Comments

@eras
Copy link

eras commented Dec 29, 2022

It seems the interface is designed so that it is impossible to create multiple DataStreams for one PeerConnection. Line 240 of lib.rs says:

    pub async fn dial(self, label: &str) -> anyhow::Result<DataStream> {

taking self in, disallowing it to be called multiple times. In datachannel-rs there is no such limitation, as can be seen from line 355 of peerconnection.rs:

    pub fn create_data_channel_ex<C>(
        &mut self,
        label: &str,
        dc_handler: C,
        dc_init: &DataChannelInit,
    ) -> Result<Box<RtcDataChannel<C>>>

The documentation for libdatachannel doesn't outright say that there can be multiple DataChannels, but it does say that rtcCreateDataChannel adds a datachannel to a Peer Connection and in general this is possible.

It can be useful to have e.g. one unordered and unreliable DataChannel paired with an ordered an reliable DataChannel.

It seems some internal changes are needed to make this happen, peer_con: Arc<Mutex<Box<RtcPeerConnection<ConnInternal>>>> in PeerConnection probably needs to be an Arc as well, for one. I guess I misread it :).

eras added a commit to eras/async-datachannel that referenced this issue Dec 29, 2022
…epted

It achieves this by making clones of peer_con and handle, which are
Arc<Mutex>>.

This interface is no longer compatible with the wasm one, however.

This addresses wngr#4
partially.
@eras
Copy link
Author

eras commented Dec 29, 2022

Turns out the native interface change was trivial, though I did only try the normal use case ;-). However, the Wasm version needs more work :/.

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

1 participant