add control reset.

This commit is contained in:
Miroslav Šedivý 2020-11-29 15:58:26 +01:00
parent 179a22476c
commit f9b62073ef
2 changed files with 19 additions and 0 deletions

View File

@ -106,3 +106,21 @@ func (h *RoomHandler) controlGive(w http.ResponseWriter, r *http.Request) {
utils.HttpSuccess(w)
}
func (h *RoomHandler) controlReset(w http.ResponseWriter, r *http.Request) {
host := h.sessions.GetHost()
if host == nil {
utils.HttpSuccess(w)
return
}
h.sessions.ClearHost()
h.sessions.Broadcast(
message.Control{
Event: event.CONTROL_RELEASE,
ID: host.ID(),
}, nil)
utils.HttpSuccess(w)
}

View File

@ -58,6 +58,7 @@ func (h *RoomHandler) Route(r chi.Router) {
r.With(auth.AdminsOnly).Post("/take", h.controlTake)
r.With(auth.AdminsOnly).Post("/give", h.controlGive)
r.With(auth.AdminsOnly).Post("/reset", h.controlReset)
})
r.Route("/screen", func(r chi.Router) {