2020-11-02 04:09:48 +13:00
|
|
|
package handler
|
2020-10-23 03:54:50 +13:00
|
|
|
|
|
|
|
import (
|
2020-10-29 07:15:48 +13:00
|
|
|
"demodesk/neko/internal/types"
|
|
|
|
"demodesk/neko/internal/types/event"
|
|
|
|
"demodesk/neko/internal/types/message"
|
2020-10-23 03:54:50 +13:00
|
|
|
)
|
|
|
|
|
2020-12-01 05:53:05 +13:00
|
|
|
func (h *MessageHandlerCtx) screenSet(session types.Session, payload *message.ScreenSize) error {
|
2021-08-30 04:23:58 +12:00
|
|
|
logger := h.logger.With().Str("session_id", session.ID()).Logger()
|
|
|
|
|
2021-03-14 12:45:51 +13:00
|
|
|
if !session.Profile().IsAdmin {
|
2021-08-30 04:23:58 +12:00
|
|
|
logger.Debug().Msg("is not the admin")
|
2020-10-23 03:54:50 +13:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-16 05:30:19 +13:00
|
|
|
if err := h.desktop.SetScreenSize(types.ScreenSize{
|
2021-02-15 02:40:17 +13:00
|
|
|
Width: payload.Width,
|
2021-01-16 05:30:19 +13:00
|
|
|
Height: payload.Height,
|
2021-02-15 02:40:17 +13:00
|
|
|
Rate: payload.Rate,
|
2021-01-16 05:30:19 +13:00
|
|
|
}); err != nil {
|
2020-11-19 08:34:33 +13:00
|
|
|
return err
|
2020-10-23 03:54:50 +13:00
|
|
|
}
|
|
|
|
|
2020-11-19 08:30:33 +13:00
|
|
|
h.sessions.Broadcast(
|
2020-12-01 05:53:05 +13:00
|
|
|
message.ScreenSize{
|
|
|
|
Event: event.SCREEN_UPDATED,
|
2020-11-17 05:48:10 +13:00
|
|
|
Width: payload.Width,
|
|
|
|
Height: payload.Height,
|
|
|
|
Rate: payload.Rate,
|
2020-11-17 06:12:25 +13:00
|
|
|
}, nil)
|
2020-11-19 08:30:33 +13:00
|
|
|
|
|
|
|
return nil
|
2020-10-23 03:54:50 +13:00
|
|
|
}
|