MCPcopy Create free account
hub / github.com/Monibuca/engine / onSuberClose

Method onSuberClose

stream.go:426–434  ·  view source on GitHub ↗
(sub ISubscriber)

Source from the content-addressed store, hash-verified

424}
425
426func (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
436func (s *Stream) checkRunCost(timeStart time.Time, timeOutInfo zap.Field) {
437 if cost := time.Since(timeStart); cost > 100*time.Millisecond {

Callers 1

runMethod · 0.95

Calls 5

actionMethod · 0.95
OnEventMethod · 0.65
LenMethod · 0.65
GetSubscriberMethod · 0.65
DeleteMethod · 0.45

Tested by

no test coverage detected