Documentation
¶
Overview ¶
Package transfer implements B2BUA-style call transfer signaling (RFC 3515 REFER + NOTIFY).
Signaling only:
- Inbound REFER → 202 Accepted + NOTIFY sipfrag
- Outbound second leg via protocol/sip/outbound.Manager.Dial
- RFC 7044 / RFC 5806 retarget headers (ApplyRetargetHeaders)
Media bridging after transfer is in protocol/sipmedia/transferbridge. Business hooks (ACD, TTS brief, CRM) stay outside this package.
Index ¶
- func ApplyRetargetHeaders(req *outbound.DialRequest, rawTo, rawHistoryInfo, rawDiversion string, ...)
- type Config
- type Coordinator
- func (c *Coordinator) HandleDialEvent(evt outbound.DialEvent)
- func (c *Coordinator) HandleDialogCallIDAdopted(oldID, newID, _ string)
- func (c *Coordinator) HandleRefer(req *stack.Message, addr *net.UDPAddr) (*stack.Message, error)
- func (c *Coordinator) SendInboundBye(callID string) error
- func (c *Coordinator) TriggerFromReferTo(ctx context.Context, inboundCallID, referToHeader string, ...)
- func (c *Coordinator) TriggerToAgent(ctx context.Context, inboundCallID string, tgt outbound.DialTarget, ...)
- type DialogState
- type DialogStore
- func (s *DialogStore) BuildBye(callID, localIP string, localPort int) (*stack.Message, *net.UDPAddr, error)
- func (s *DialogStore) BuildNotify(callID, localIP string, localPort int, sipfragBody, subscriptionState string) (*stack.Message, *net.UDPAddr, error)
- func (s *DialogStore) Forget(callID string)
- func (s *DialogStore) Get(callID string) *DialogState
- func (s *DialogStore) Remember(callID string, remote *net.UDPAddr, inv *stack.Message, ourToWithTag string)
- type RetargetSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyRetargetHeaders ¶
func ApplyRetargetHeaders( req *outbound.DialRequest, rawTo, rawHistoryInfo, rawDiversion string, historyReason, diversionReason string, )
ApplyRetargetHeaders mutates req to include History-Info and Diversion chains for B2BUA retarget.
Types ¶
type Config ¶
type Config struct {
Dialogs *DialogStore
LocalIP string
SIPPort int
Dial func(ctx context.Context, req outbound.DialRequest) (string, error)
SendSIP func(msg *stack.Message, addr *net.UDPAddr) error
Retarget RetargetSource
}
Config initializes a signaling-only transfer coordinator.
type Coordinator ¶
type Coordinator struct {
Dialogs *DialogStore
LocalIP string
SIPPort int
Dial func(ctx context.Context, req outbound.DialRequest) (string, error)
SendSIP func(msg *stack.Message, addr *net.UDPAddr) error
Retarget RetargetSource
// contains filtered or unexported fields
}
Coordinator wires REFER signaling and outbound transfer dial (signaling only). Media bridging lives in protocol/sipmedia/transferbridge.
func NewCoordinator ¶
func NewCoordinator(cfg Config) *Coordinator
NewCoordinator builds a transfer coordinator.
func (*Coordinator) HandleDialEvent ¶
func (c *Coordinator) HandleDialEvent(evt outbound.DialEvent)
HandleDialEvent should be wired to outbound.ManagerConfig.OnEvent. Fires pending REFER NOTIFY on established/failed. Media bridge is handled by sipmedia/transferbridge.
func (*Coordinator) HandleDialogCallIDAdopted ¶
func (c *Coordinator) HandleDialogCallIDAdopted(oldID, newID, _ string)
HandleDialogCallIDAdopted rekeys pending REFER NOTIFY when SBC rewrites outbound Call-ID.
func (*Coordinator) HandleRefer ¶
HandleRefer answers inbound REFER with 202 and starts outbound transfer asynchronously.
func (*Coordinator) SendInboundBye ¶
func (c *Coordinator) SendInboundBye(callID string) error
SendInboundBye sends BYE on the inbound dialog and forgets dialog state.
func (*Coordinator) TriggerFromReferTo ¶
func (c *Coordinator) TriggerFromReferTo(ctx context.Context, inboundCallID, referToHeader string, onTerminalNotify func(sipfrag, subState string))
TriggerFromReferTo dials Refer-To target (signaling); bridge separately via sipmedia.
func (*Coordinator) TriggerToAgent ¶
func (c *Coordinator) TriggerToAgent(ctx context.Context, inboundCallID string, tgt outbound.DialTarget, onTerminalNotify func(sipfrag, subState string))
TriggerToAgent dials an agent/trunk target for AI or ACD-driven transfer.
type DialogState ¶
type DialogState struct {
Remote *net.UDPAddr
From string // our To from 200 OK (local tag)
To string // remote From from INVITE
RequestURI string
NextCSeq int
}
DialogState holds in-dialog routing data for NOTIFY/BYE on an inbound UAS leg.
type DialogStore ¶
type DialogStore struct {
// contains filtered or unexported fields
}
DialogStore tracks confirmed inbound dialogs keyed by Call-ID.
func NewDialogStore ¶
func NewDialogStore() *DialogStore
NewDialogStore creates an empty dialog map.
func (*DialogStore) BuildBye ¶
func (s *DialogStore) BuildBye(callID, localIP string, localPort int) (*stack.Message, *net.UDPAddr, error)
BuildBye builds an in-dialog BYE for the inbound leg.
func (*DialogStore) BuildNotify ¶
func (s *DialogStore) BuildNotify(callID, localIP string, localPort int, sipfragBody, subscriptionState string) (*stack.Message, *net.UDPAddr, error)
BuildNotify builds an in-dialog NOTIFY (Event: refer) with message/sipfrag body.
func (*DialogStore) Forget ¶
func (s *DialogStore) Forget(callID string)
Forget removes dialog state (after BYE or teardown).
func (*DialogStore) Get ¶
func (s *DialogStore) Get(callID string) *DialogState
Get returns dialog state for callID.
type RetargetSource ¶
RetargetSource supplies inbound History-Info / Diversion context for outbound retarget INVITEs. Implementations typically read from protocol/sipmedia/session.CallSession metadata.