mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-10 07:37:26 +02:00
add control status.
This commit is contained in:
parent
628abe06fd
commit
fb6dabf4e0
2 changed files with 21 additions and 0 deletions
|
@ -9,10 +9,30 @@ import (
|
||||||
"demodesk/neko/internal/http/auth"
|
"demodesk/neko/internal/http/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ControlStatusPayload struct {
|
||||||
|
HasHost bool `json:"has_host"`
|
||||||
|
HostId string `json:"host_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type ControlTargetPayload struct {
|
type ControlTargetPayload struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *RoomHandler) controlStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
|
host := h.sessions.GetHost()
|
||||||
|
|
||||||
|
if host == nil {
|
||||||
|
utils.HttpSuccess(w, ControlStatusPayload{
|
||||||
|
HasHost: false,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
utils.HttpSuccess(w, ControlStatusPayload{
|
||||||
|
HasHost: true,
|
||||||
|
HostId: host.ID(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) controlRequest(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) controlRequest(w http.ResponseWriter, r *http.Request) {
|
||||||
host := h.sessions.GetHost()
|
host := h.sessions.GetHost()
|
||||||
if host != nil {
|
if host != nil {
|
||||||
|
|
|
@ -52,6 +52,7 @@ func (h *RoomHandler) Route(r chi.Router) {
|
||||||
})
|
})
|
||||||
|
|
||||||
r.Route("/control", func(r chi.Router) {
|
r.Route("/control", func(r chi.Router) {
|
||||||
|
r.Get("/", h.controlStatus)
|
||||||
r.Post("/request", h.controlRequest)
|
r.Post("/request", h.controlRequest)
|
||||||
r.Post("/release", h.controlRelease)
|
r.Post("/release", h.controlRelease)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue