Skip to content

Commit

Permalink
refactor: Rename event handler constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
rg0now committed Dec 10, 2024
1 parent cbb0e01 commit 8afc1fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ func (s *Stunner) NewStatusHandler() object.StatusHandler {
return func() stnrv1.Status { return s.Status() }
}

var lifecycleEventHandlerConstructor = newLifecycleEventHandlerStub
var eventHandlerConstructor = newEventHandlerStub

// NewLifecycleEventHandler creates a set of callbcks for tracking the lifecycle of TURN allocations.
func (s *Stunner) NewLifecycleEventHandler() turn.EventHandlers {
return lifecycleEventHandlerConstructor(s)
// NewEventHandler creates a set of callbcks for tracking the lifecycle of TURN allocations.
func (s *Stunner) NewEventHandler() turn.EventHandlers {
return eventHandlerConstructor(s)
}

// LifecycleEventHandlerStub is a simple stub that logs allocation events.
func newLifecycleEventHandlerStub(s *Stunner) turn.EventHandlers {
func newEventHandlerStub(s *Stunner) turn.EventHandlers {
return turn.EventHandlers{
OnAuth: func(src, dst net.Addr, proto, username, realm string, method string, verdict bool) {
status := "REJECTED"
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (s *Stunner) StartServer(l *object.Listener) error {
t, err := turn.NewServer(turn.ServerConfig{
Realm: s.GetRealm(),
AuthHandler: s.NewAuthHandler(),
EventHandlers: s.NewLifecycleEventHandler(),
EventHandlers: s.NewEventHandler(),
PacketConnConfigs: pConns,
ListenerConfigs: lConns,
LoggerFactory: logger.NewRateLimitedLoggerFactory(s.logger, LogRateLimit, LogBurst),
Expand Down

0 comments on commit 8afc1fd

Please sign in to comment.