(timeout time.Duration)
| 692 | } |
| 693 | |
| 694 | func (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 | |
| 722 | func (c *RTCClient) ReadResponse() (*livekit.SignalResponse, error) { |
| 723 | for { |
no test coverage detected