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

Severing a connection #286

Closed
simbleau opened this issue Aug 3, 2023 · 3 comments · Fixed by #337
Closed

Severing a connection #286

simbleau opened this issue Aug 3, 2023 · 3 comments · Fixed by #337
Labels
enhancement New feature or request question Further information is requested

Comments

@simbleau
Copy link
Collaborator

simbleau commented Aug 3, 2023

In #283 I noticed something - We don't have a way to disconnect or sever a connection between two parties.

How can we go about this?

This is super useful. In a client/server architecture, the server may want to kick the client, for example!

@simbleau simbleau added question Further information is requested enhancement New feature or request labels Aug 3, 2023
@simbleau
Copy link
Collaborator Author

simbleau commented Aug 3, 2023

@simbleau
Copy link
Collaborator Author

I keep looking into this but it's not making sense how we could sever a connection.

My goal is for a peer to specifically stop listening, and end another peer's connection.

@simbleau
Copy link
Collaborator Author

Ok so it was going to go in #283 but I'm just going to drop the code here so I can re-add it back later.

impl WebRtcChannel {
    /// Returns whether this channel is closed
    pub fn is_closed(&self) -> bool {
        self.tx.is_closed()
    }
}

impl<C: ChannelPlurality> WebRtcSocket<C> {
    /// Returns whether this socket is closed; this is considered closed as soon as any channel (not
    /// taken) is closed.
    pub fn is_closed(&self) -> bool {
        self.channels
            .iter()
            .filter_map(Option::as_ref)
            .any(|c| c.is_closed())
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant