76 lines
1.5 KiB
Go
Raw Normal View History

2020-11-01 16:09:48 +01:00
package handler
import (
"github.com/demodesk/neko/pkg/types"
"github.com/demodesk/neko/pkg/types/event"
"github.com/demodesk/neko/pkg/types/message"
)
2020-12-02 18:59:54 +01:00
func (h *MessageHandlerCtx) SessionCreated(session types.Session) error {
h.sessions.Broadcast(
2021-09-01 21:58:39 +02:00
event.SESSION_CREATED,
2021-03-14 00:05:31 +01:00
message.SessionData{
2020-12-03 16:10:52 +01:00
ID: session.ID(),
2021-03-14 00:45:51 +01:00
Profile: session.Profile(),
State: session.State(),
})
2020-12-02 18:59:54 +01:00
return nil
}
func (h *MessageHandlerCtx) SessionDeleted(session types.Session) error {
h.sessions.Broadcast(
2021-09-01 21:58:39 +02:00
event.SESSION_DELETED,
2021-03-14 00:05:31 +01:00
message.SessionID{
2021-09-01 21:58:39 +02:00
ID: session.ID(),
})
2020-12-02 18:59:54 +01:00
return nil
}
2020-11-01 16:09:48 +01:00
func (h *MessageHandlerCtx) SessionConnected(session types.Session) error {
2020-11-30 20:07:19 +01:00
if err := h.systemInit(session); err != nil {
return err
}
2021-03-14 00:45:51 +01:00
if session.Profile().IsAdmin {
2020-11-30 20:07:19 +01:00
if err := h.systemAdmin(session); err != nil {
return err
}
}
return h.SessionStateChanged(session)
}
2020-11-01 20:53:25 +01:00
func (h *MessageHandlerCtx) SessionDisconnected(session types.Session) error {
// clear host if exists
2020-11-01 20:53:25 +01:00
if session.IsHost() {
2020-12-02 10:46:00 +01:00
h.desktop.ResetKeys()
h.sessions.ClearHost()
}
return h.SessionStateChanged(session)
}
2020-12-02 18:59:54 +01:00
2020-12-03 16:10:52 +01:00
func (h *MessageHandlerCtx) SessionProfileChanged(session types.Session) error {
2020-12-02 18:59:54 +01:00
h.sessions.Broadcast(
2021-09-01 21:58:39 +02:00
event.SESSION_PROFILE,
2020-12-02 18:59:54 +01:00
message.MemberProfile{
2020-12-08 15:14:20 +01:00
ID: session.ID(),
2021-09-01 21:58:39 +02:00
MemberProfile: session.Profile(),
})
2020-12-02 18:59:54 +01:00
return nil
}
2020-12-03 16:10:52 +01:00
func (h *MessageHandlerCtx) SessionStateChanged(session types.Session) error {
h.sessions.Broadcast(
2021-09-01 21:58:39 +02:00
event.SESSION_STATE,
2021-03-13 23:42:16 +01:00
message.SessionState{
ID: session.ID(),
2021-09-01 21:58:39 +02:00
SessionState: session.State(),
})
2020-12-03 16:10:52 +01:00
return nil
}