MCPcopy
hub / github.com/livekit/livekit / WaitUntilConnected

Method WaitUntilConnected

test/client/client.go:694–720  ·  view source on GitHub ↗
(timeout time.Duration)

Source from the content-addressed store, hash-verified

692}
693
694func (c *RTCClient) WaitUntilConnected(timeout time.Duration) error {
695 if timeout == 0 {
696 timeout = 20 * time.Second
697 }
698 ctx, cancel := context.WithTimeout(context.Background(), timeout)
699 defer cancel()
700 for {
701 select {
702 case <-ctx.Done():
703 id := string(c.ID())
704 if c.localParticipant != nil {
705 id = c.localParticipant.Identity
706 }
707 return fmt.Errorf("%s could not connect after timeout", id)
708 case <-time.After(10 * time.Millisecond):
709 if c.subscriberAsPrimary.Load() {
710 if c.subscriberFullyEstablished.Load() {
711 return nil
712 }
713 } else {
714 if c.publisherFullyEstablished.Load() {
715 return nil
716 }
717 }
718 }
719 }
720}
721
722func (c *RTCClient) ReadResponse() (*livekit.SignalResponse, error) {
723 for {

Callers 2

waitUntilConnectedFunction · 0.80
ensureNotConnectedFunction · 0.80

Calls 3

IDMethod · 0.95
DoneMethod · 0.80
LoadMethod · 0.65

Tested by

no test coverage detected