Fix data publish test (#113)
This commit is contained in:
+2
-10
@@ -244,18 +244,13 @@ func (c *RTCClient) Run() error {
|
|||||||
return nil
|
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
|
// run the session
|
||||||
for {
|
for {
|
||||||
res, err := c.ReadResponse()
|
res, err := c.ReadResponse()
|
||||||
if errors.Is(io.EOF, err) {
|
if errors.Is(io.EOF, err) {
|
||||||
return nil
|
return nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
logger.Errorw("error while reading", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
switch msg := res.Message.(type) {
|
switch msg := res.Message.(type) {
|
||||||
@@ -269,8 +264,6 @@ func (c *RTCClient) Run() error {
|
|||||||
c.lock.Unlock()
|
c.lock.Unlock()
|
||||||
|
|
||||||
logger.Infow("join accepted, awaiting offer", "participant", msg.Join.Participant.Identity)
|
logger.Infow("join accepted, awaiting offer", "participant", msg.Join.Participant.Identity)
|
||||||
|
|
||||||
defer c.Stop()
|
|
||||||
case *livekit.SignalResponse_Answer:
|
case *livekit.SignalResponse_Answer:
|
||||||
//logger.Debugw("received server answer",
|
//logger.Debugw("received server answer",
|
||||||
// "participant", c.localParticipant.Identity,
|
// "participant", c.localParticipant.Identity,
|
||||||
@@ -529,7 +522,6 @@ func (c *RTCClient) PublishData(data []byte, kind livekit.DataPacket_Kind) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Infow("trying to publish")
|
|
||||||
if kind == livekit.DataPacket_RELIABLE {
|
if kind == livekit.DataPacket_RELIABLE {
|
||||||
return c.reliableDC.Send(payload)
|
return c.reliableDC.Send(payload)
|
||||||
} else {
|
} else {
|
||||||
@@ -556,7 +548,7 @@ func (c *RTCClient) ensurePublisherConnected() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// wait until connected
|
// wait until connected
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|||||||
+1
-1
@@ -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 {
|
testutils.WithTimeout(t, "waiting for c2 to receive data", func() bool {
|
||||||
return received.Get()
|
return received.Get()
|
||||||
|
|||||||
Reference in New Issue
Block a user