basic integration test

This commit is contained in:
David Zhao
2021-01-13 13:41:34 -08:00
parent 09e5a37c75
commit 233306d83a
6 changed files with 114 additions and 24 deletions
+15
View File
@@ -3,6 +3,7 @@ package client
import (
"container/ring"
"context"
"errors"
"fmt"
"io"
"net/http"
@@ -254,6 +255,20 @@ func (c *RTCClient) Run() error {
return nil
}
func (c *RTCClient) WaitUntilConnected() error {
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
for {
select {
case <-ctx.Done():
return errors.New("could not connect after timeout")
case <-time.After(10 * time.Millisecond):
if c.iceConnected {
return nil
}
}
}
}
func (c *RTCClient) ReadResponse() (*livekit.SignalResponse, error) {
for {
// handle special messages and pass on the rest