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,12 +2,15 @@ package room
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/http/auth"
|
"demodesk/neko/internal/http/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RoomHandler struct {
|
type RoomHandler struct {
|
||||||
|
logger zerolog.Logger
|
||||||
sessions types.SessionManager
|
sessions types.SessionManager
|
||||||
desktop types.DesktopManager
|
desktop types.DesktopManager
|
||||||
capture types.CaptureManager
|
capture types.CaptureManager
|
||||||
@ -18,9 +21,13 @@ func New(
|
|||||||
desktop types.DesktopManager,
|
desktop types.DesktopManager,
|
||||||
capture types.CaptureManager,
|
capture types.CaptureManager,
|
||||||
) *RoomHandler {
|
) *RoomHandler {
|
||||||
// Init
|
logger := log.With().
|
||||||
|
Str("module", "api").
|
||||||
|
Str("submodule", "room").
|
||||||
|
Logger()
|
||||||
|
|
||||||
return &RoomHandler{
|
return &RoomHandler{
|
||||||
|
logger: logger,
|
||||||
sessions: sessions,
|
sessions: sessions,
|
||||||
desktop: desktop,
|
desktop: desktop,
|
||||||
capture: capture,
|
capture: capture,
|
||||||
|
@ -3,7 +3,10 @@ package room
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"demodesk/neko/internal/types/event"
|
||||||
|
"demodesk/neko/internal/types/message"
|
||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
|
"demodesk/neko/internal/http/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScreenConfiguration struct {
|
type ScreenConfiguration struct {
|
||||||
@ -38,7 +41,17 @@ func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.R
|
|||||||
return
|
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)
|
utils.HttpSuccess(w, data)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user