Subscribe creates a channel that receives command results for a session.
(sessionID, subID string)
| 302 | |
| 303 | // Subscribe creates a channel that receives command results for a session. |
| 304 | func (m *Manager) Subscribe(sessionID, subID string) <-chan *CommandResult { |
| 305 | sess := m.Get(sessionID) |
| 306 | if sess == nil { |
| 307 | return nil |
| 308 | } |
| 309 | ch := make(chan *CommandResult, subscriberChannelSize) |
| 310 | sess.mu.Lock() |
| 311 | defer sess.mu.Unlock() |
| 312 | sess.subscribers[subID] = ch |
| 313 | return ch |
| 314 | } |
| 315 | |
| 316 | // Unsubscribe removes a subscriber and closes its channel. |
| 317 | func (m *Manager) Unsubscribe(sessionID, subID string) { |