CloseSession closes a specific session by ID.
(sessionID string)
| 496 | |
| 497 | // CloseSession closes a specific session by ID. |
| 498 | func (sm *SessionManager) CloseSession(sessionID string) error { |
| 499 | sm.mutex.Lock() |
| 500 | defer sm.mutex.Unlock() |
| 501 | |
| 502 | session, exists := sm.sessions[sessionID] |
| 503 | if !exists { |
| 504 | return fmt.Errorf("session not found: %s", sessionID) |
| 505 | } |
| 506 | |
| 507 | if sm.logger != nil { |
| 508 | sm.logger.Info("Closing VNC session: session_id=%s, target_type=%s, target_name=%s", |
| 509 | sessionID, session.TargetType, session.TargetName) |
| 510 | } |
| 511 | |
| 512 | // Shutdown the session |
| 513 | err := session.Shutdown() |
| 514 | if err != nil && sm.logger != nil { |
| 515 | sm.logger.Error("Failed to shutdown session: session_id=%s, error=%v", sessionID, err) |
| 516 | } |
| 517 | |
| 518 | // Remove from sessions map |
| 519 | delete(sm.sessions, sessionID) |
| 520 | |
| 521 | // Notify callback of session count change |
| 522 | sm.notifySessionCountChange() |
| 523 | |
| 524 | return err |
| 525 | } |
| 526 | |
| 527 | // CloseAllSessions closes all active sessions. |
| 528 | func (sm *SessionManager) CloseAllSessions() error { |
nothing calls this directly
no test coverage detected