mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
REST screen change broadcast.
This commit is contained in:
parent
e8f9e2e4e4
commit
227b6b24c2
@ -2,15 +2,18 @@ package room
|
||||
|
||||
import (
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"demodesk/neko/internal/types"
|
||||
"demodesk/neko/internal/http/auth"
|
||||
)
|
||||
|
||||
type RoomHandler struct {
|
||||
logger zerolog.Logger
|
||||
sessions types.SessionManager
|
||||
desktop types.DesktopManager
|
||||
capture types.CaptureManager
|
||||
capture types.CaptureManager
|
||||
}
|
||||
|
||||
func New(
|
||||
@ -18,9 +21,13 @@ func New(
|
||||
desktop types.DesktopManager,
|
||||
capture types.CaptureManager,
|
||||
) *RoomHandler {
|
||||
// Init
|
||||
logger := log.With().
|
||||
Str("module", "api").
|
||||
Str("submodule", "room").
|
||||
Logger()
|
||||
|
||||
return &RoomHandler{
|
||||
logger: logger,
|
||||
sessions: sessions,
|
||||
desktop: desktop,
|
||||
capture: capture,
|
||||
|
@ -3,7 +3,10 @@ package room
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"demodesk/neko/internal/types/event"
|
||||
"demodesk/neko/internal/types/message"
|
||||
"demodesk/neko/internal/utils"
|
||||
"demodesk/neko/internal/http/auth"
|
||||
)
|
||||
|
||||
type ScreenConfiguration struct {
|
||||
@ -38,7 +41,17 @@ func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.R
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Broadcast change to all sessions.
|
||||
session := auth.GetSession(r)
|
||||
if err := h.sessions.Broadcast(
|
||||
message.ScreenResolution{
|
||||
Event: event.SCREEN_RESOLUTION,
|
||||
ID: session.ID(),
|
||||
Width: data.Width,
|
||||
Height: data.Height,
|
||||
Rate: data.Rate,
|
||||
}, nil); err != nil {
|
||||
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.SCREEN_RESOLUTION)
|
||||
}
|
||||
|
||||
utils.HttpSuccess(w, data)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user