👌 IMPROVE:对外推流索引改为以url为键,优化SSE代码

This commit is contained in:
dexter
2022-10-07 22:42:07 +08:00
parent 265ab7c723
commit 9454ded0ee
7 changed files with 102 additions and 63 deletions

View File

@@ -314,10 +314,10 @@ func (opt *Plugin) Push(streamPath string, url string, pusher IPusher, save bool
if err = opt.Subscribe(streamPath, pusher); err != nil {
return
}
Pushers.Store(pusher, url)
Pushers.Store(url, pusher)
go func() {
defer opt.Info("push finished", zp, zu)
defer Pushers.Delete(pusher)
defer Pushers.Delete(url)
for pusher.Reconnect() {
opt.Info("start push", zp, zu)
if err = pusher.Push(); !pusher.IsClosed() {
@@ -337,7 +337,7 @@ func (opt *Plugin) Push(streamPath string, url string, pusher IPusher, save bool
}()
if save {
pushConfig.AddPush(streamPath, url)
pushConfig.AddPush(url, streamPath)
if opt.Modified == nil {
opt.Modified = make(config.Config)
}