Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/api/invitation-accept-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { SessionDescriptionHandlerModifier, SessionDescriptionHandlerOptions } f
* @public
*/
export interface InvitationAcceptOptions {
/**
* Array of extra headers added to the response.
*/
extraHeaders?: Array<string>;
/**
* Modifiers to pass to SessionDescriptionHandler during the initial INVITE transaction.
*/
Expand Down
10 changes: 6 additions & 4 deletions src/api/invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class Invitation extends Session {
this.stateTransition(SessionState.Establishing);

return (
this.sendAccept()
this.sendAccept(options)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.then(({ message, session }) => {
session.delegate = {
Expand Down Expand Up @@ -565,12 +565,14 @@ export class Invitation extends Session {
* A version of `accept` which resolves a session when the 200 Ok response is sent.
* @param options - Options bucket.
*/
private sendAccept(): Promise<OutgoingResponseWithSession> {
private sendAccept(options: InvitationAcceptOptions = {}): Promise<OutgoingResponseWithSession> {
const responseOptions = {
sessionDescriptionHandlerOptions: this.sessionDescriptionHandlerOptions,
sessionDescriptionHandlerModifiers: this.sessionDescriptionHandlerModifiers
};

const extraHeaders = options.extraHeaders || [];

// The UAS MAY send a final response to the initial request before
// having received PRACKs for all unacknowledged reliable provisional
// responses, unless the final response is 2xx and any of the
Expand All @@ -588,12 +590,12 @@ export class Invitation extends Session {
return this.waitForArrivalOfPrack()
.then(() => clearTimeout(this.userNoAnswerTimer)) // Ported
.then(() => this.generateResponseOfferAnswer(this.incomingInviteRequest, responseOptions))
.then((body) => this.incomingInviteRequest.accept({ statusCode: 200, body }));
.then((body) => this.incomingInviteRequest.accept({ statusCode: 200, body, extraHeaders }));
}

clearTimeout(this.userNoAnswerTimer); // Ported
return this.generateResponseOfferAnswer(this.incomingInviteRequest, responseOptions).then((body) =>
this.incomingInviteRequest.accept({ statusCode: 200, body })
this.incomingInviteRequest.accept({ statusCode: 200, body, extraHeaders })
);
}

Expand Down