Skip to content

Commit

Permalink
fix: observer should use SafeEmit
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxinfei committed Aug 8, 2022
1 parent e58cedd commit 313a094
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion router.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (router *Router) close() {
router.mapRouterPipeTransports = sync.Map{}

// Emit observer event.
router.observer.Emit("close")
router.observer.SafeEmit("close")
}

// Dump Router.
Expand Down
8 changes: 4 additions & 4 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,9 @@ func (w *Worker) Close() {
w.waitCh <- w.diedErr

if w.diedErr != nil {
w.Emit("died", w.diedErr)
w.SafeEmit("died", w.diedErr)
}
w.observer.Emit("close")
w.observer.SafeEmit("close")
}

// Dump returns the resources allocated by the worker.
Expand Down Expand Up @@ -557,7 +557,7 @@ func (w *Worker) CreateWebRtcServer(options WebRtcServerOptions) (webRtcServer *
})

// Emit observer event.
w.observer.Emit("newwebrtcserver", webRtcServer)
w.observer.SafeEmit("newwebrtcserver", webRtcServer)

return
}
Expand Down Expand Up @@ -592,7 +592,7 @@ func (w *Worker) CreateRouter(options RouterOptions) (router *Router, err error)
})

// Emit observer event.
w.observer.Emit("newrouter", router)
w.observer.SafeEmit("newrouter", router)

return
}

0 comments on commit 313a094

Please sign in to comment.