(sub ISubscriber)
| 424 | } |
| 425 | |
| 426 | func (s *Stream) onSuberClose(sub ISubscriber) { |
| 427 | s.Subscribers.Delete(sub) |
| 428 | if s.Publisher != nil { |
| 429 | s.Publisher.OnEvent(sub) // 通知Publisher有订阅者离开,在回调中可以去获取订阅者数量 |
| 430 | } |
| 431 | if (s.DelayCloseTimeout > 0 || s.IdleTimeout > 0) && s.Subscribers.Len() == 0 && !sub.GetSubscriber().Config.Internal { |
| 432 | s.action(ACTION_LASTLEAVE) |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | func (s *Stream) checkRunCost(timeStart time.Time, timeOutInfo zap.Field) { |
| 437 | if cost := time.Since(timeStart); cost > 100*time.Millisecond { |