Skip to content

Refactor: extract shared finalizeCall helper for internal and trunk 200 OK handling #46

Description

@thorsager

Background

Issue #41 extracts a callCtx struct to remove the long parameter lists in the B2BUA response loops. Once that is complete, handleTrunk200OK and handleBob200OK still contain nearly identical logic for:

  • parsing Bob's SDP and extracting the RTP address,
  • building and sending the ACK to Bob,
  • constructing the 200 OK answer to Alice,
  • creating media.Session, media.Bridge, sip.Dialog, and Call objects,
  • starting the bridge (early vs delayed offer).

Goal

Extract a shared helper that finalizes a successful B2BUA call for both internal and trunk legs:

func (h *Handler) finalizeCall(ctx context.Context, cc *callCtx, resp *proto.SIPMessage, bobTo *proto.SIPAddress) *Call

The helper should accept the trunk-specific data it needs (e.g. trunkName, bobReqURI, sessionExpires) as additional parameters, or via optional fields in a small trunk-specific wrapper.

Acceptance criteria

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions