From 1b0f99521038c3d247422ced39f160f6b2cfd5a7 Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Wed, 12 Jan 2022 10:00:03 +0800 Subject: [PATCH] fix: Use sip.Message instead of sip.Request for GetBranchID, close #76. --- pkg/ua/ua.go | 4 ++-- pkg/utils/util.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/ua/ua.go b/pkg/ua/ua.go index e56c8e3..38726ba 100644 --- a/pkg/ua/ua.go +++ b/pkg/ua/ua.go @@ -492,7 +492,7 @@ func (ua *UserAgent) RequestWithContext(ctx context.Context, request sip.Request case provisional := <-provisionals: callID, ok := provisional.CallID() if ok { - branchID := utils.GetBranchID(provisional.(sip.Request)) + branchID := utils.GetBranchID(provisional) if v, found := ua.iss.Load(NewSessionKey(*callID, branchID)); found { is := v.(*session.Session) is.StoreResponse(provisional) @@ -527,7 +527,7 @@ func (ua *UserAgent) RequestWithContext(ctx context.Context, request sip.Request case response := <-responses: callID, ok := response.CallID() if ok { - branchID := utils.GetBranchID(response.(sip.Request)) + branchID := utils.GetBranchID(response) if v, found := ua.iss.Load(NewSessionKey(*callID, branchID)); found { if request.IsInvite() { is := v.(*session.Session) diff --git a/pkg/utils/util.go b/pkg/utils/util.go index 37aa175..73647c7 100644 --- a/pkg/utils/util.go +++ b/pkg/utils/util.go @@ -16,8 +16,8 @@ var ( ErrPort = errors.New("invalid port") ) -func GetBranchID(request sip.Request) sip.MaybeString { - if viaHop, ok := request.ViaHop(); ok { +func GetBranchID(msg sip.Message) sip.MaybeString { + if viaHop, ok := msg.ViaHop(); ok { if branch, ok := viaHop.Params.Get("branch"); ok { return branch }