mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-12-24 13:48:04 +08:00
- fix: panic generated by concurrent creation of streams for publishing and subscribing - fix: IdleTimeout invalid issue - fix: read and write concurrency issues caused by subscriber blocking - Preview plugin fixes the default port for https - GB28181 plugin PR merge - 启动工程增加对流的发布订阅的单元测试和基准测试 - 修复发布和订阅并发创建流产生的panic - 修复IdleTimeout无效问题 - 修复订阅者阻塞导致读写并发问题 - preview插件修复https默认端口 - gb28181插件PR合并
34 lines
604 B
Go
34 lines
604 B
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
. "m7s.live/engine/v4"
|
|
)
|
|
|
|
type SlowSubsciber struct {
|
|
Subscriber
|
|
}
|
|
|
|
func (s *SlowSubsciber) OnEvent(event any) {
|
|
switch event.(type) {
|
|
case AudioFrame:
|
|
case VideoFrame:
|
|
// 模拟慢消费,导致长时间占用后被发布者移除
|
|
time.Sleep(1000 * time.Millisecond)
|
|
default:
|
|
s.Subscriber.OnEvent(event)
|
|
}
|
|
}
|
|
|
|
func TestSlowSubscriber(t *testing.T) {
|
|
t.Cleanup(FreeEngine)
|
|
UseEngine()
|
|
var pub UnitTestPublisher
|
|
unitTestPlugin.Publish("test/slow", &pub)
|
|
var suber SlowSubsciber
|
|
unitTestPlugin.Subscribe("test/slow", &suber)
|
|
suber.PlayRaw()
|
|
}
|