Skip to content

Commit

Permalink
Make client tx callbacks options as struct
Browse files Browse the repository at this point in the history
  • Loading branch information
ghettovoice committed Aug 27, 2024
1 parent c47233b commit 1db32b6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
}

0 comments on commit 1db32b6

Please sign in to comment.