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

Add OnOfferConnected channel for synchronize connected event for client #966

Merged
merged 1 commit into from
May 9, 2024

Conversation

billfort
Copy link
Contributor

@billfort billfort commented May 9, 2024

No description provided.

@@ -99,8 +100,11 @@ func (c *Peer) Offer(label string) error {
if err != nil {
return err
}

c.OnOfferConnected = make(chan struct{}, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to move this to constructer because very often people use it this way:

peer := NewPeer(...)
go func() { ... <-peer.OnOfferConnected ... }
peer.Offer()

so OnOfferConnected needs to be created when creating peer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, modified.

dc.OnOpen(func() {
log.Debugf("Data channel %v has been opened\n", dc.Label())
c.OnOfferConnected <- struct{}{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to use default to prevent blocking since Offer() can be called multiple times

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, modified.

@yilunzhang yilunzhang merged commit 24ade56 into nknorg:master May 9, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants