Skip to content

Commit

Permalink
Cancel register-refresh goroutine after un-registered.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Mar 20, 2021
1 parent c10e7e9 commit cb97c36
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/register/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func main() {
Password: "100",
Realm: "b2bua",
},
30,
1800,
stack,
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/ua/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (r *Register) SendRegister(expires uint32) error {

contact := profile.Contact()

if r.request == nil {
if r.request == nil || expires == 0 {
request, err := ua.buildRequest(sip.REGISTER, from, to, contact, recipient, nil)
if err != nil {
ua.Log().Errorf("Register: err = %v", err)
Expand Down Expand Up @@ -138,6 +138,7 @@ func (r *Register) SendRegister(expires uint32) error {
r.timer.Stop()
r.timer = nil
}
r.cancel()
}
ua.RegisterStateHandler(state)
}
Expand Down

0 comments on commit cb97c36

Please sign in to comment.