Skip to content

Commit

Permalink
When sending ACK/BYE use Route not Record-Route
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean-Der committed Nov 29, 2023
1 parent 8e5450c commit ce185ef
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net"
"os"
"os/signal"
"sync/atomic"
"time"

"github.com/at-wat/ebml-go"
Expand Down Expand Up @@ -289,6 +290,11 @@ func main() {
inviteRequest.Recipient = &contactHeader.Address
inviteRequest.Recipient.Port = 5060
}

if recordRouteHeader, ok := inviteResponse.RecordRoute(); ok {
inviteRequest.AppendHeader(&sip.RouteHeader{Address: recordRouteHeader.Address})
}

sipClient.WriteRequest(sip.NewAckRequest(inviteRequest, inviteResponse, nil))

sendBye := func() {
Expand All @@ -304,13 +310,17 @@ func main() {
mediaConn.Close()
}

byeSent := atomic.Bool{}
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt)
go func() {
<-signalChan
sendBye()
byeSent.Store(true)
}()

sendAudioPackets(mediaConn, inviteResponse.Body())
sendBye()
if !byeSent.Load() {
sendBye()
}
}

0 comments on commit ce185ef

Please sign in to comment.