| 336 | } |
| 337 | |
| 338 | func (s *Server) getSession(id string) (session, bool) { |
| 339 | if id == "" { |
| 340 | return session{}, false |
| 341 | } |
| 342 | s.mu.Lock() |
| 343 | defer s.mu.Unlock() |
| 344 | currentSession, ok := s.sessions[id] |
| 345 | if !ok || currentSession == nil { |
| 346 | return session{}, false |
| 347 | } |
| 348 | now := time.Now() |
| 349 | if sessionExpired(currentSession, now) { |
| 350 | delete(s.sessions, id) |
| 351 | return session{}, false |
| 352 | } |
| 353 | currentSession.lastUsedAt = now |
| 354 | return *currentSession, true |
| 355 | } |
| 356 | |
| 357 | func (s *Server) markSessionInitialized(id string) bool { |
| 358 | s.mu.Lock() |