diff --git a/publisher.go b/publisher.go index a787abe..979fc0d 100644 --- a/publisher.go +++ b/publisher.go @@ -197,9 +197,7 @@ func (p *Publisher) Start() (err error) { s.Waiting.WakeUp(p.StreamPath, p) p.processAliasOnStart() - for plugin := range s.Plugins.Range { - plugin.OnPublish(p) - } + p.Plugin.Server.OnPublish(p) //s.Transforms.PublishEvent <- p p.AddTask(&PublishTimeout{Publisher: p}) if p.PublishTimeout > 0 { diff --git a/push-proxy.go b/push-proxy.go index f83190d..5313da0 100644 --- a/push-proxy.go +++ b/push-proxy.go @@ -108,8 +108,17 @@ func (d *PushProxy) ChangeStatus(status byte) { d.Update() switch status { case PushProxyStatusOnline: - if d.PushOnStart && from == PushProxyStatusOffline { - d.Handler.Push() + if from == PushProxyStatusOffline { + if d.PushOnStart { + d.Handler.Push() + } else { + d.server.Streams.Call(func() error { + if d.server.Streams.Has(d.GetStreamPath()) { + d.Handler.Push() + } + return nil + }) + } } } } diff --git a/server.go b/server.go index f0cf565..bcea153 100644 --- a/server.go +++ b/server.go @@ -569,6 +569,17 @@ func (s *Server) Dispose() { } } +func (s *Server) OnPublish(p *Publisher) { + for plugin := range s.Plugins.Range { + plugin.OnPublish(p) + } + for pushProxy := range s.PushProxies.Range { + if pushProxy.Status == PushProxyStatusOnline && pushProxy.GetStreamPath() == p.StreamPath && !pushProxy.PushOnStart { + pushProxy.Handler.Push() + } + } +} + func (s *Server) OnSubscribe(streamPath string, args url.Values) { for plugin := range s.Plugins.Range { plugin.OnSubscribe(streamPath, args)