mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-05 16:46:58 +08:00
处理订阅时的意外情况
This commit is contained in:
@@ -2,7 +2,6 @@ package engine
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Monibuca/engine/v2/avformat"
|
"github.com/Monibuca/engine/v2/avformat"
|
||||||
@@ -49,10 +48,13 @@ func (s *Subscriber) Close() {
|
|||||||
func (s *Subscriber) Subscribe(streamPath string) (err error) {
|
func (s *Subscriber) Subscribe(streamPath string) (err error) {
|
||||||
if !config.EnableWaitStream {
|
if !config.EnableWaitStream {
|
||||||
if _, ok := streamCollection.Load(streamPath); !ok {
|
if _, ok := streamCollection.Load(streamPath); !ok {
|
||||||
return errors.New(fmt.Sprintf("Stream not found:%s", streamPath))
|
return errors.Errorf("Stream not found:%s", streamPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GetStream(streamPath).Subscribe(s)
|
GetStream(streamPath).Subscribe(s)
|
||||||
|
if s.Context == nil {
|
||||||
|
return errors.Errorf("stream not exist:%s", streamPath)
|
||||||
|
}
|
||||||
defer s.UnSubscribe(s)
|
defer s.UnSubscribe(s)
|
||||||
select {
|
select {
|
||||||
//等待发布者首屏数据,如果发布者尚为发布,则会等待,否则就会往下执行
|
//等待发布者首屏数据,如果发布者尚为发布,则会等待,否则就会往下执行
|
||||||
|
Reference in New Issue
Block a user