Shutdown gracefully shuts down this VNC session, stopping the HTTP server and cleaning up all associated resources.
()
| 164 | // Shutdown gracefully shuts down this VNC session, stopping the HTTP server |
| 165 | // and cleaning up all associated resources. |
| 166 | func (s *VNCSession) Shutdown() error { |
| 167 | s.mutex.Lock() |
| 168 | defer s.mutex.Unlock() |
| 169 | |
| 170 | // Mark session as closed |
| 171 | s.State = SessionStateClosed |
| 172 | |
| 173 | // Cancel the session context |
| 174 | if s.cancelFunc != nil { |
| 175 | s.cancelFunc() |
| 176 | } |
| 177 | |
| 178 | // Close the disconnect channel |
| 179 | if s.disconnectChan != nil { |
| 180 | close(s.disconnectChan) |
| 181 | s.disconnectChan = nil |
| 182 | } |
| 183 | |
| 184 | // Stop the HTTP server |
| 185 | if s.Server != nil { |
| 186 | return s.Server.Stop() |
| 187 | } |
| 188 | |
| 189 | return nil |
| 190 | } |
| 191 | |
| 192 | // SessionCountCallback is called when the session count changes. |
| 193 | type SessionCountCallback func(count int) |