Fixed room API breakage (#190)
This commit is contained in:
@@ -181,7 +181,7 @@ func (r *RedisRouter) WriteRTCMessage(ctx context.Context, roomName, identity st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *RedisRouter) WriteRTCNodeMessage(ctx context.Context, rtcNodeID string, msg *livekit.RTCNodeMessage) error {
|
func (r *RedisRouter) WriteRTCNodeMessage(ctx context.Context, rtcNodeID string, msg *livekit.RTCNodeMessage) error {
|
||||||
rtcSink := NewRTCNodeSink(r.rc, rtcNodeID, "")
|
rtcSink := NewRTCNodeSink(r.rc, rtcNodeID, msg.ParticipantKey)
|
||||||
return r.writeRTCMessage(rtcSink, msg)
|
return r.writeRTCMessage(rtcSink, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -464,15 +464,18 @@ func (r *LocalRoomManager) handleRTCMessage(ctx context.Context, roomName, ident
|
|||||||
}
|
}
|
||||||
|
|
||||||
participant := room.GetParticipant(identity)
|
participant := room.GetParticipant(identity)
|
||||||
if participant == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
switch rm := msg.Message.(type) {
|
switch rm := msg.Message.(type) {
|
||||||
case *livekit.RTCNodeMessage_RemoveParticipant:
|
case *livekit.RTCNodeMessage_RemoveParticipant:
|
||||||
|
if participant == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
logger.Infow("removing participant", "room", roomName, "participant", identity)
|
logger.Infow("removing participant", "room", roomName, "participant", identity)
|
||||||
room.RemoveParticipant(identity)
|
room.RemoveParticipant(identity)
|
||||||
case *livekit.RTCNodeMessage_MuteTrack:
|
case *livekit.RTCNodeMessage_MuteTrack:
|
||||||
|
if participant == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
logger.Debugw("setting track muted", "room", roomName, "participant", identity,
|
logger.Debugw("setting track muted", "room", roomName, "participant", identity,
|
||||||
"track", rm.MuteTrack.TrackSid, "muted", rm.MuteTrack.Muted)
|
"track", rm.MuteTrack.TrackSid, "muted", rm.MuteTrack.Muted)
|
||||||
if !rm.MuteTrack.Muted && !r.config.Room.EnableRemoteUnmute {
|
if !rm.MuteTrack.Muted && !r.config.Room.EnableRemoteUnmute {
|
||||||
@@ -481,6 +484,9 @@ func (r *LocalRoomManager) handleRTCMessage(ctx context.Context, roomName, ident
|
|||||||
}
|
}
|
||||||
participant.SetTrackMuted(rm.MuteTrack.TrackSid, rm.MuteTrack.Muted, true)
|
participant.SetTrackMuted(rm.MuteTrack.TrackSid, rm.MuteTrack.Muted, true)
|
||||||
case *livekit.RTCNodeMessage_UpdateParticipant:
|
case *livekit.RTCNodeMessage_UpdateParticipant:
|
||||||
|
if participant == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
logger.Debugw("updating participant", "room", roomName, "participant", identity)
|
logger.Debugw("updating participant", "room", roomName, "participant", identity)
|
||||||
if rm.UpdateParticipant.Metadata != "" {
|
if rm.UpdateParticipant.Metadata != "" {
|
||||||
participant.SetMetadata(rm.UpdateParticipant.Metadata)
|
participant.SetMetadata(rm.UpdateParticipant.Metadata)
|
||||||
@@ -494,6 +500,9 @@ func (r *LocalRoomManager) handleRTCMessage(ctx context.Context, roomName, ident
|
|||||||
}
|
}
|
||||||
room.Close()
|
room.Close()
|
||||||
case *livekit.RTCNodeMessage_UpdateSubscriptions:
|
case *livekit.RTCNodeMessage_UpdateSubscriptions:
|
||||||
|
if participant == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
logger.Debugw("updating participant subscriptions", "room", roomName, "participant", identity)
|
logger.Debugw("updating participant subscriptions", "room", roomName, "participant", identity)
|
||||||
if err := room.UpdateSubscriptions(participant, rm.UpdateSubscriptions.TrackSids, rm.UpdateSubscriptions.Subscribe); err != nil {
|
if err := room.UpdateSubscriptions(participant, rm.UpdateSubscriptions.TrackSids, rm.UpdateSubscriptions.Subscribe); err != nil {
|
||||||
logger.Warnw("could not update subscription", err,
|
logger.Warnw("could not update subscription", err,
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ func (s *RoomService) DeleteRoom(ctx context.Context, req *livekit.DeleteRoomReq
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = s.router.WriteRTCNodeMessage(ctx, node.Id, &livekit.RTCNodeMessage{
|
err = s.router.WriteRTCNodeMessage(ctx, node.Id, &livekit.RTCNodeMessage{
|
||||||
|
ParticipantKey: s.roomParticipantKey(req.Room),
|
||||||
Message: &livekit.RTCNodeMessage_DeleteRoom{
|
Message: &livekit.RTCNodeMessage_DeleteRoom{
|
||||||
DeleteRoom: req,
|
DeleteRoom: req,
|
||||||
},
|
},
|
||||||
@@ -198,6 +199,7 @@ func (s *RoomService) SendData(ctx context.Context, req *livekit.SendDataRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = s.router.WriteRTCNodeMessage(ctx, node.Id, &livekit.RTCNodeMessage{
|
err = s.router.WriteRTCNodeMessage(ctx, node.Id, &livekit.RTCNodeMessage{
|
||||||
|
ParticipantKey: s.roomParticipantKey(req.Room),
|
||||||
Message: &livekit.RTCNodeMessage_SendData{
|
Message: &livekit.RTCNodeMessage_SendData{
|
||||||
SendData: req,
|
SendData: req,
|
||||||
},
|
},
|
||||||
@@ -227,6 +229,7 @@ func (s *RoomService) UpdateRoomMetadata(ctx context.Context, req *livekit.Updat
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = s.router.WriteRTCNodeMessage(ctx, node.Id, &livekit.RTCNodeMessage{
|
err = s.router.WriteRTCNodeMessage(ctx, node.Id, &livekit.RTCNodeMessage{
|
||||||
|
ParticipantKey: s.roomParticipantKey(req.Room),
|
||||||
Message: &livekit.RTCNodeMessage_UpdateRoomMetadata{
|
Message: &livekit.RTCNodeMessage_UpdateRoomMetadata{
|
||||||
UpdateRoomMetadata: req,
|
UpdateRoomMetadata: req,
|
||||||
},
|
},
|
||||||
@@ -250,3 +253,7 @@ func (s *RoomService) writeMessage(ctx context.Context, room, identity string, m
|
|||||||
|
|
||||||
return s.router.WriteRTCMessage(ctx, room, identity, msg)
|
return s.router.WriteRTCMessage(ctx, room, identity, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *RoomService) roomParticipantKey(room string) string {
|
||||||
|
return room + "|"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user