AutoUnsubscribe will issue an automatic Unsubscribe that is processed by the server when max messages have been received. This can be useful when sending a request to an unknown number of subscribers.
(max int)
| 5265 | // This can be useful when sending a request to an unknown number |
| 5266 | // of subscribers. |
| 5267 | func (s *Subscription) AutoUnsubscribe(max int) error { |
| 5268 | if s == nil { |
| 5269 | return ErrBadSubscription |
| 5270 | } |
| 5271 | s.mu.Lock() |
| 5272 | conn := s.conn |
| 5273 | closed := s.closed |
| 5274 | s.mu.Unlock() |
| 5275 | if conn == nil || closed { |
| 5276 | return ErrBadSubscription |
| 5277 | } |
| 5278 | return conn.unsubscribe(s, max, false) |
| 5279 | } |
| 5280 | |
| 5281 | // SetClosedHandler will set the closed handler for when a subscription |
| 5282 | // is closed (either unsubscribed or drained). |