GetByPrefix returns the first session whose ID starts with the given prefix. Returns nil if no session matches or prefix is empty.
(prefix string)
| 121 | // GetByPrefix returns the first session whose ID starts with the given prefix. |
| 122 | // Returns nil if no session matches or prefix is empty. |
| 123 | func (m *Manager) GetByPrefix(prefix string) *Session { |
| 124 | if prefix == "" { |
| 125 | return nil |
| 126 | } |
| 127 | m.mu.RLock() |
| 128 | defer m.mu.RUnlock() |
| 129 | for id, sess := range m.sessions { |
| 130 | if strings.HasPrefix(id, prefix) { |
| 131 | return sess |
| 132 | } |
| 133 | } |
| 134 | return nil |
| 135 | } |
| 136 | |
| 137 | // List returns summaries of all active sessions. |
| 138 | func (m *Manager) List() []SessionSummary { |
no outgoing calls