client sends offer after getting room info
@@ -34,6 +34,7 @@ type RTCClient struct {
paused bool
me *rtc.MediaEngine // optional, populated only when receiving tracks
receivers []*rtc.Receiver
+ localParticipant *livekit.ParticipantInfo
// pending actions to start after connected to peer
pendingCandidates []*webrtc.ICECandidate
@@ -174,7 +175,16 @@ func (c *RTCClient) Run() error {
c.AppendLog("data channel open")
})
- c.AppendLog("creating offer")
+ // run the session
+ for {
+ res, err := c.ReadResponse()
+ if err != nil {
+ return err
+ }
+ switch msg := res.Message.(type) {
+ case *livekit.SignalResponse_Join:
+ c.AppendLog("join accepted, sending offer..")
+ c.localParticipant = msg.Join.Participant
// Create an offer to send to the other process
offer, err := c.PeerConn.CreateOffer(nil)
@@ -202,14 +212,6 @@ func (c *RTCClient) Run() error {
}
defer c.PeerConn.Close()
-
- // run the session
- for {
- res, err := c.ReadResponse()
- if err != nil {
- return err
- }
- switch msg := res.Message.(type) {
case *livekit.SignalResponse_Answer:
c.AppendLog("connected to remote, setting desc")
// remote answered the offer, establish connection
