Skip to content

Commit

Permalink
adding a OnRebind call back to notify users when rebind was successful
Browse files Browse the repository at this point in the history
  • Loading branch information
laduchesneau committed Nov 11, 2023
1 parent 7bfd2f8 commit 917fb50
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,8 @@ type Settings struct {
// manual response/handling is needed
OnAllPDU func(pdu pdu.PDU) pdu.PDU

// OnRebind notifies `rebind` event due to State.
OnRebind RebindCallback

response func(pdu.PDU)
}
3 changes: 3 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ func (s *Session) rebind() {

// reset rebinding state
atomic.StoreInt32(&s.rebinding, 0)
if s.settings.OnRebind != nil {
s.settings.OnRebind()
}

return
}
Expand Down
3 changes: 3 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ type ErrorCallback func(error)

// ClosedCallback notifies closed event due to State.
type ClosedCallback func(State)

// RebindCallback notifies rebind event due to State.
type RebindCallback func()

0 comments on commit 917fb50

Please sign in to comment.