subscriber.go 423 B

123456789101112131415161718192021222324
  1. package webtransport
  2. import (
  3. "go.uber.org/zap"
  4. . "m7s.live/engine/v4"
  5. "m7s.live/engine/v4/codec"
  6. )
  7. type WebTransportSubscriber struct {
  8. Subscriber
  9. }
  10. func (wt *WebTransportSubscriber) OnEvent(event any) {
  11. switch v := event.(type) {
  12. case ISubscriber:
  13. wt.Write(codec.FLVHeader)
  14. case FLVFrame:
  15. if _, err := v.WriteTo(wt); err != nil {
  16. wt.Stop(zap.Error(err))
  17. }
  18. default:
  19. wt.Subscriber.OnEvent(event)
  20. }
  21. }