(msg proto.Message)
| 42 | } |
| 43 | |
| 44 | func (s *signalhandler) HandleMessage(msg proto.Message) error { |
| 45 | req, ok := msg.(*livekit.SignalRequest) |
| 46 | if !ok { |
| 47 | s.params.Logger.Warnw( |
| 48 | "unknown message type", nil, |
| 49 | "messageType", fmt.Sprintf("%T", msg), |
| 50 | ) |
| 51 | return ErrInvalidMessageType |
| 52 | } |
| 53 | s.params.Participant.UpdateLastSeenSignal() |
| 54 | |
| 55 | s.params.Logger.Debugw("handling signal request", "request", logger.Proto(req)) |
| 56 | switch msg := req.GetMessage().(type) { |
| 57 | case *livekit.SignalRequest_Offer: |
| 58 | s.params.Participant.HandleOffer(msg.Offer) |
| 59 | |
| 60 | case *livekit.SignalRequest_Answer: |
| 61 | s.params.Participant.HandleAnswer(msg.Answer) |
| 62 | |
| 63 | case *livekit.SignalRequest_Trickle: |
| 64 | s.params.Participant.HandleICETrickle(msg.Trickle) |
| 65 | |
| 66 | case *livekit.SignalRequest_AddTrack: |
| 67 | s.params.Participant.AddTrack(msg.AddTrack) |
| 68 | |
| 69 | case *livekit.SignalRequest_Mute: |
| 70 | s.params.Participant.SetTrackMuted(msg.Mute, false) |
| 71 | |
| 72 | case *livekit.SignalRequest_Subscription: |
| 73 | // allow participant to indicate their interest in the subscription |
| 74 | // permission check happens later in SubscriptionManager |
| 75 | s.params.Participant.HandleUpdateSubscriptions( |
| 76 | livekit.StringsAsIDs[livekit.TrackID](msg.Subscription.TrackSids), |
| 77 | msg.Subscription.ParticipantTracks, |
| 78 | msg.Subscription.Subscribe, |
| 79 | ) |
| 80 | |
| 81 | case *livekit.SignalRequest_TrackSetting: |
| 82 | for _, sid := range livekit.StringsAsIDs[livekit.TrackID](msg.TrackSetting.TrackSids) { |
| 83 | s.params.Participant.UpdateSubscribedTrackSettings(sid, msg.TrackSetting) |
| 84 | } |
| 85 | |
| 86 | case *livekit.SignalRequest_Leave: |
| 87 | reason := types.ParticipantCloseReasonClientRequestLeave |
| 88 | switch msg.Leave.Reason { |
| 89 | case livekit.DisconnectReason_CLIENT_INITIATED: |
| 90 | reason = types.ParticipantCloseReasonClientRequestLeave |
| 91 | case livekit.DisconnectReason_USER_UNAVAILABLE: |
| 92 | reason = types.ParticipantCloseReasonUserUnavailable |
| 93 | case livekit.DisconnectReason_USER_REJECTED: |
| 94 | reason = types.ParticipantCloseReasonUserRejected |
| 95 | case livekit.DisconnectReason_AGENT_ERROR: |
| 96 | reason = types.ParticipantCloseReasonAgentError |
| 97 | } |
| 98 | s.params.Logger.Debugw("client leaving room", "reason", reason) |
| 99 | s.params.Participant.HandleLeaveRequest(reason) |
| 100 | |
| 101 | case *livekit.SignalRequest_SubscriptionPermission: |
nothing calls this directly
no test coverage detected