mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add session to settings change.
This commit is contained in:
@ -39,7 +39,7 @@ func (h *MessageHandlerCtx) SessionConnected(session types.Session) error {
|
||||
}
|
||||
|
||||
// update settings in atomic way
|
||||
h.sessions.UpdateSettingsFunc(func(settings *types.Settings) bool {
|
||||
h.sessions.UpdateSettingsFunc(session, func(settings *types.Settings) bool {
|
||||
// if control protection & locked controls: unlock controls
|
||||
if settings.LockedControls && settings.ControlProtection {
|
||||
settings.LockedControls = false
|
||||
@ -70,7 +70,7 @@ func (h *MessageHandlerCtx) SessionDisconnected(session types.Session) error {
|
||||
})
|
||||
|
||||
// update settings in atomic way
|
||||
h.sessions.UpdateSettingsFunc(func(settings *types.Settings) bool {
|
||||
h.sessions.UpdateSettingsFunc(session, func(settings *types.Settings) bool {
|
||||
// if control protection & not locked controls & no admin: lock controls
|
||||
if !settings.LockedControls && settings.ControlProtection && !hasAdmin {
|
||||
settings.LockedControls = true
|
||||
|
@ -127,7 +127,7 @@ func (manager *WebSocketManagerCtx) Start() {
|
||||
Msg("session host changed")
|
||||
})
|
||||
|
||||
manager.sessions.OnSettingsChanged(func(new types.Settings, old types.Settings) {
|
||||
manager.sessions.OnSettingsChanged(func(session types.Session, new types.Settings, old types.Settings) {
|
||||
// start inactive cursors
|
||||
if new.InactiveCursors && !old.InactiveCursors {
|
||||
manager.startInactiveCursors()
|
||||
@ -138,8 +138,13 @@ func (manager *WebSocketManagerCtx) Start() {
|
||||
manager.stopInactiveCursors()
|
||||
}
|
||||
|
||||
manager.sessions.Broadcast(event.SYSTEM_SETTINGS, new)
|
||||
manager.sessions.Broadcast(event.SYSTEM_SETTINGS, message.SystemSettingsUpdate{
|
||||
ID: session.ID(),
|
||||
Settings: new,
|
||||
})
|
||||
|
||||
manager.logger.Info().
|
||||
Str("session_id", session.ID()).
|
||||
Interface("new", new).
|
||||
Interface("old", old).
|
||||
Msg("settings changed")
|
||||
|
Reference in New Issue
Block a user