Skip to content

Commit 2006661

Browse files
committed
Dropping the wrapper
1 parent 5f3b852 commit 2006661

2 files changed

Lines changed: 12 additions & 26 deletions

File tree

pkg/sip/client.go

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,17 @@ import (
4040
)
4141

4242
// An interface mirroring sipgo.Client to be able to mock it in tests.
43+
// Note: *sipgo.Client implements this interface directly, so no wrapper is needed.
4344
type SIPClient interface {
44-
TransactionRequest(req *sip.Request) (sip.ClientTransaction, error)
45-
WriteRequest(req *sip.Request) error
45+
TransactionRequest(req *sip.Request, options ...sipgo.ClientRequestOption) (sip.ClientTransaction, error)
46+
WriteRequest(req *sip.Request, options ...sipgo.ClientRequestOption) error
4647
Close() error
4748
}
4849

49-
// Passthrough implementation of SIPClient with a sipgo.Client.
50-
type sipgoClientWrapper struct {
51-
client *sipgo.Client
52-
}
53-
54-
func (w *sipgoClientWrapper) TransactionRequest(req *sip.Request) (sip.ClientTransaction, error) {
55-
return w.client.TransactionRequest(req)
56-
}
57-
58-
func (w *sipgoClientWrapper) WriteRequest(req *sip.Request) error {
59-
return w.client.WriteRequest(req)
60-
}
61-
62-
func (w *sipgoClientWrapper) Close() error {
63-
return w.client.Close()
64-
}
65-
6650
type GetSipClientFunc func(ua *sipgo.UserAgent, options ...sipgo.ClientOption) (SIPClient, error)
6751

6852
func DefaultGetSipClientFunc(ua *sipgo.UserAgent, options ...sipgo.ClientOption) (SIPClient, error) {
69-
client, err := sipgo.NewClient(ua, options...)
70-
if err != nil {
71-
return nil, err
72-
}
73-
return &sipgoClientWrapper{client: client}, nil
53+
return sipgo.NewClient(ua, options...)
7454
}
7555

7656
type Client struct {

pkg/sip/outbound_utilities_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,10 @@ func (w *testSIPClient) FillRequestBlanks(req *sip.Request) {
363363
}
364364
}
365365

366-
func (w *testSIPClient) TransactionRequest(req *sip.Request) (sip.ClientTransaction, error) {
366+
func (w *testSIPClient) TransactionRequest(req *sip.Request, options ...sipgo.ClientRequestOption) (sip.ClientTransaction, error) {
367+
if len(options) > 0 {
368+
panic("options not supported for testSIPClient")
369+
}
367370
fmt.Printf("SIP TransactionRequest sent on client %v:\n%s\n", w, req.String())
368371
w.FillRequestBlanks(req)
369372
w.sequence++
@@ -386,7 +389,10 @@ func (w *testSIPClient) TransactionRequest(req *sip.Request) (sip.ClientTransact
386389
}
387390
}
388391

389-
func (w *testSIPClient) WriteRequest(req *sip.Request) error {
392+
func (w *testSIPClient) WriteRequest(req *sip.Request, options ...sipgo.ClientRequestOption) error {
393+
if len(options) > 0 {
394+
panic("options not supported for testSIPClient")
395+
}
390396
fmt.Printf("SIP WriteRequest sent on client %v:\n%s\n", w, req.String())
391397
w.FillRequestBlanks(req)
392398
w.sequence++

0 commit comments

Comments
 (0)