diff --git a/src/api/ack.ts b/src/api/ack.ts new file mode 100644 index 000000000..6298a20da --- /dev/null +++ b/src/api/ack.ts @@ -0,0 +1,15 @@ +import { IncomingRequestMessage, IncomingAckRequest } from "../core"; + +/** + * A request to confirm a {@link Session} (incoming ACK). + * @public + */ +export class Ack { + /** @internal */ + public constructor(private incomingAckRequest: IncomingAckRequest) {} + + /** Incoming ACK request message. */ + public get request(): IncomingRequestMessage { + return this.incomingAckRequest.message; + } +} diff --git a/src/api/index.ts b/src/api/index.ts index 88daf1474..7a318eec5 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -3,6 +3,7 @@ * @packageDocumentation */ export * from "./exceptions"; +export * from "./ack"; export * from "./bye"; export * from "./emitter"; export * from "./info"; diff --git a/src/api/session-delegate.ts b/src/api/session-delegate.ts index cde5ab583..0a3f492ce 100644 --- a/src/api/session-delegate.ts +++ b/src/api/session-delegate.ts @@ -1,4 +1,5 @@ import { IncomingRequestMessage } from "../core"; +import { Ack } from "./ack"; import { Bye } from "./bye"; import { Info } from "./info"; import { Message } from "./message"; @@ -11,6 +12,12 @@ import { SessionDescriptionHandler } from "./session-description-handler"; * @public */ export interface SessionDelegate { + /** + * Called upon receiving an incoming in dialog ACK request. + * @param ack - The ack. + */ + onAck?(ack: Ack): void; + /** * Called upon receiving an incoming in dialog BYE request. * @param bye - The bye. diff --git a/src/api/session.ts b/src/api/session.ts index 17cc9f254..f9090fcdf 100644 --- a/src/api/session.ts +++ b/src/api/session.ts @@ -29,6 +29,7 @@ import { } from "../core"; import { getReasonPhrase } from "../core/messages/utils"; import { AllowedMethods } from "../core/user-agent-core/allowed-methods"; +import { Ack } from "./ack"; import { Bye } from "./bye"; import { Emitter, EmitterImpl } from "./emitter"; import { ContentTypeUnsupportedError, RequestPendingError } from "./exceptions"; @@ -793,6 +794,11 @@ export abstract class Session { : this._sessionDescriptionHandlerModifiers }; + if (this.delegate && this.delegate.onAck) { + const ack = new Ack(request); + this.delegate.onAck(ack); + } + // reset pending ACK flag this.pendingReinviteAck = false;