Skip to content

Commit 19f646c

Browse files
committed
Add InviteWithContext for UserAgent.
1 parent ef095f7 commit 19f646c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/ua/ua.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ func (ua *UserAgent) SendRegister(profile *account.Profile, recipient sip.SipUri
126126
}
127127

128128
func (ua *UserAgent) Invite(profile *account.Profile, target sip.Uri, recipient sip.SipUri, body *string) (*session.Session, error) {
129+
return ua.InviteWithContext(context.TODO(), profile, target, recipient, body)
130+
}
131+
132+
func (ua *UserAgent) InviteWithContext(ctx context.Context, profile *account.Profile, target sip.Uri, recipient sip.SipUri, body *string) (*session.Session, error) {
129133

130134
from := &sip.Address{
131135
DisplayName: sip.String{Str: profile.DisplayName},
@@ -156,7 +160,7 @@ func (ua *UserAgent) Invite(profile *account.Profile, target sip.Uri, recipient
156160
authorizer = auth.NewClientAuthorizer(profile.AuthInfo.AuthUser, profile.AuthInfo.Password)
157161
}
158162

159-
resp, err := ua.RequestWithContext(context.TODO(), *request, authorizer, false, 1)
163+
resp, err := ua.RequestWithContext(ctx, *request, authorizer, false, 1)
160164
if err != nil {
161165
ua.Log().Errorf("INVITE: Request [INVITE] failed, err => %v", err)
162166
return nil, err

0 commit comments

Comments
 (0)