(force bool)
| 350 | } |
| 351 | |
| 352 | func (s *LivekitServer) Stop(force bool) { |
| 353 | // wait for all participants to exit |
| 354 | s.router.Drain() |
| 355 | partTicker := time.NewTicker(5 * time.Second) |
| 356 | waitingForParticipants := !force && s.roomManager.HasParticipants() |
| 357 | for waitingForParticipants { |
| 358 | <-partTicker.C |
| 359 | logger.Infow("waiting for participants to exit") |
| 360 | waitingForParticipants = s.roomManager.HasParticipants() |
| 361 | } |
| 362 | partTicker.Stop() |
| 363 | |
| 364 | if !s.running.Swap(false) { |
| 365 | return |
| 366 | } |
| 367 | |
| 368 | s.router.Stop() |
| 369 | close(s.doneChan) |
| 370 | |
| 371 | // wait for fully closed |
| 372 | <-s.closedChan |
| 373 | } |
| 374 | |
| 375 | func (s *LivekitServer) RoomManager() *RoomManager { |
| 376 | return s.roomManager |
no test coverage detected