diff --git a/cmd/cli/client/client.go b/cmd/cli/client/client.go index 04992072b..e8cab486e 100644 --- a/cmd/cli/client/client.go +++ b/cmd/cli/client/client.go @@ -184,6 +184,7 @@ func (c *RTCClient) Run() error { case *livekit.SignalResponse_Join: c.AppendLog("join accepted, sending offer..") c.localParticipant = msg.Join.Participant + c.AppendLog("other participants", "count", len(msg.Join.OtherParticipants)) // Create an offer to send to the other process offer, err := c.PeerConn.CreateOffer(nil) @@ -240,6 +241,10 @@ func (c *RTCClient) Run() error { if err := c.PeerConn.AddICECandidate(*candidateInit); err != nil { return err } + case *livekit.SignalResponse_Update: + for _, p := range msg.Update.Participants { + c.AppendLog("participant update", "id", p.Id, "state", p.State.String()) + } } } diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 6250eb27d..7e7d46703 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -119,10 +119,12 @@ func (p *Participant) State() livekit.ParticipantInfo_State { } func (p *Participant) ToProto() *livekit.ParticipantInfo { - return &livekit.ParticipantInfo{ - Id: p.id, - Name: p.name, + info := &livekit.ParticipantInfo{ + Id: p.id, + Name: p.name, + State: p.state, } + return info } // Answer an offer from remote participant @@ -280,6 +282,7 @@ func (p *Participant) updateState(state livekit.ParticipantInfo_State) { } oldState := p.state p.state = state + if p.OnStateChange != nil { go func() { p.OnStateChange(p, oldState) diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index 99b0ff486..29c4a91e3 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -60,13 +60,16 @@ func (r *Room) Join(participant *Participant) error { r.lock.Lock() defer r.lock.Unlock() - participant.OnPeerTrack = r.onTrackAdded + log := logger.GetLogger() + // it's important to set this before connection, we don't want to miss out on any tracks + participant.OnPeerTrack = r.onTrackAdded participant.OnStateChange = func(p *Participant, oldState livekit.ParticipantInfo_State) { + log.Debugw("participant state changed", "state", p.state, "participant", p.id) r.broadcastParticipantState(p) } - logger.GetLogger().Infow("new participant joined", + log.Infow("new participant joined", "id", participant.ID(), "name", participant.Name(), "roomId", r.Id) @@ -137,7 +140,7 @@ func (r *Room) broadcastParticipantState(p *Participant) { continue } - err := p.SendParticipantUpdate(updates) + err := op.SendParticipantUpdate(updates) if err != nil { logger.GetLogger().Errorw("could not send update to participant", "participant", p.id, diff --git a/pkg/utils/id.go b/pkg/utils/id.go index 1771cb52e..6d72a2c60 100644 --- a/pkg/utils/id.go +++ b/pkg/utils/id.go @@ -5,9 +5,9 @@ import ( ) const ( - RoomPrefix = "R-" - NodePrefix = "N-" - ParticipantPrefix = "P-" + RoomPrefix = "RM_" + NodePrefix = "ND_" + ParticipantPrefix = "PA_" ) func NewGuid(prefix string) string {