func watch(session *janus.Session, handle *janus.Handle, stop chan struct{}) { for { msg := <-handle.Events switch msg := msg.(type) { case *janus.MediaMsg: if msg.Receiving == "false" { handle.Detach() session.Destroy() close(stop) return } } } }