Closed kuzmig closed 2 weeks ago
Hello @kuzmig , yeah, I agree, this can be useful.
There is a main problem how to not break current API (at least until I will introduce the new version).
I think, that it is possible to add new method(s) to setup callbacks on the client transaction, something like OnCancel(fn func(req sip.Request))
and OnAck(fn func(req sip.Request))
. In the callback there is possible to update generated ACK/CANCEL request in any way before sending.
Callback approach looks good for me.
Done in 24d12c01bb2419918bb944a59486c5dc0a22d39b.
// tx - sip.ClientTransaction
tx.OnAck(func(ackReq sip.Request) {
...
})
tx.OnCancel(func(cancReq sip.Request) { ... })
2. With server's RequestWithContext method:
```go
// srv - gosip.Server
srv.RequestWithContext(ctx, inviteReq,
gosip.WithClientTransactionCallbacks(gosip.ClientTransactionCallbacks{
OnAck: func(ackReq sip.Request) { ... },
OnCancel: func(cancReq sip.Request) { ... },
})
)
Looks great! Will give it a try today. Thank you very much!
Works good! Thanks!
Hello!
When transaction user calls tx.Cancel() client transaction generates SIP CANCEL request using sip.NewCancelRequest and sends it directly to the transport layer. sip.NewCancelRequest creates requests with predefined headers and, as result, there is no way to add any extra headers to this request. The same situation we have for ACK request generated by client transaction for 300+ response.
Is it possible to provide the ability to pass some "common headers" to the transaction?