From 1db32b6b4ecffbfa7a22e6089cdef2910a02c563 Mon Sep 17 00:00:00 2001 From: Vladimir Vershinin Date: Tue, 27 Aug 2024 11:50:14 +0300 Subject: [PATCH] Make client tx callbacks options as struct --- options.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/options.go b/options.go index f2b2591..8656d0b 100644 --- a/options.go +++ b/options.go @@ -7,8 +7,12 @@ type RequestWithContextOption interface { } type RequestWithContextOptions struct { - ResponseHandler func(res sip.Response, request sip.Request) - Authorizer sip.Authorizer + ResponseHandler func(res sip.Response, request sip.Request) + Authorizer sip.Authorizer + ClientTransactionCallbacks +} + +type ClientTransactionCallbacks struct { OnAckFn, OnCancelFn func(sip.Request) } @@ -36,15 +40,15 @@ func WithAuthorizer(authorizer sip.Authorizer) RequestWithContextOption { return withAuthorizer{authorizer} } -type withCallbacks struct { +type withClientTxCallbacks struct { onAckFn, onCancFn func(sip.Request) } -func WithCallbacks(onAckFn, onCancFn func(sip.Request)) RequestWithContextOption { - return withCallbacks{onAckFn, onCancFn} +func WithClientTransactionCallbacks(callbacks ClientTransactionCallbacks) RequestWithContextOption { + return withClientTxCallbacks{callbacks.OnAckFn, callbacks.OnCancelFn} } -func (o withCallbacks) ApplyRequestWithContext(options *RequestWithContextOptions) { +func (o withClientTxCallbacks) ApplyRequestWithContext(options *RequestWithContextOptions) { options.OnAckFn = o.onAckFn options.OnCancelFn = o.onCancFn }