Fix data publish test (#113)

This commit is contained in:
David Zhao
2021-09-12 00:25:36 -07:00
committed by GitHub
parent 66997b37f9
commit 95a5e3ca85
2 changed files with 3 additions and 11 deletions
+2 -10
View File
@@ -244,18 +244,13 @@ func (c *RTCClient) Run() error {
return nil
})
// create a data channel, in order to work
_, err := c.publisher.PeerConnection().CreateDataChannel("_lossy", nil)
if err != nil {
return err
}
// run the session
for {
res, err := c.ReadResponse()
if errors.Is(io.EOF, err) {
return nil
} else if err != nil {
logger.Errorw("error while reading", err)
return err
}
switch msg := res.Message.(type) {
@@ -269,8 +264,6 @@ func (c *RTCClient) Run() error {
c.lock.Unlock()
logger.Infow("join accepted, awaiting offer", "participant", msg.Join.Participant.Identity)
defer c.Stop()
case *livekit.SignalResponse_Answer:
//logger.Debugw("received server answer",
// "participant", c.localParticipant.Identity,
@@ -529,7 +522,6 @@ func (c *RTCClient) PublishData(data []byte, kind livekit.DataPacket_Kind) error
return err
}
logger.Infow("trying to publish")
if kind == livekit.DataPacket_RELIABLE {
return c.reliableDC.Send(payload)
} else {
@@ -556,7 +548,7 @@ func (c *RTCClient) ensurePublisherConnected() error {
}
// wait until connected
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
for {
select {
+1 -1
View File
@@ -134,7 +134,7 @@ func scenarioDataPublish(t *testing.T) {
}
}
require.NoError(t, c1.PublishData([]byte(payload), livekit.DataPacket_LOSSY))
require.NoError(t, c1.PublishData([]byte(payload), livekit.DataPacket_RELIABLE))
testutils.WithTimeout(t, "waiting for c2 to receive data", func() bool {
return received.Get()