ue-softphone-sdk 2.2.2 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/bye.d.ts +16 -0
- package/dist/api/dtmf.d.ts +15 -0
- package/dist/api/emitter.d.ts +88 -0
- package/dist/api/exceptions/content-type-unsupported.d.ts +8 -0
- package/dist/api/exceptions/index.d.ts +5 -0
- package/dist/api/exceptions/request-pending.d.ts +9 -0
- package/dist/api/exceptions/session-description-handler.d.ts +8 -0
- package/dist/api/exceptions/session-terminated.d.ts +8 -0
- package/dist/api/exceptions/state-transition.d.ts +8 -0
- package/dist/api/index.d.ts +58 -0
- package/dist/api/info.d.ts +16 -0
- package/dist/api/invitation-accept-options.d.ts +19 -0
- package/dist/api/invitation-progress-options.d.ts +38 -0
- package/dist/api/invitation-reject-options.d.ts +25 -0
- package/dist/api/invitation.d.ts +179 -0
- package/dist/api/inviter-cancel-options.d.ts +9 -0
- package/dist/api/inviter-invite-options.d.ts +28 -0
- package/dist/api/inviter-options.d.ts +43 -0
- package/dist/api/inviter.d.ts +236 -0
- package/dist/api/message.d.ts +16 -0
- package/dist/api/messager-message-options.d.ts +11 -0
- package/dist/api/messager-options.d.ts +17 -0
- package/dist/api/messager.d.ts +26 -0
- package/dist/api/notification.d.ts +16 -0
- package/dist/api/notifier.d.ts +8 -0
- package/dist/api/publisher-options.d.ts +33 -0
- package/dist/api/publisher-publish-options.d.ts +6 -0
- package/dist/api/publisher-state.d.ts +21 -0
- package/dist/api/publisher-unpublish-options.d.ts +6 -0
- package/dist/api/publisher.d.ts +65 -0
- package/dist/api/referral.d.ts +38 -0
- package/dist/api/registerer-options.d.ts +46 -0
- package/dist/api/registerer-register-options.d.ts +11 -0
- package/dist/api/registerer-state.d.ts +21 -0
- package/dist/api/registerer-unregister-options.d.ts +16 -0
- package/dist/api/registerer.d.ts +144 -0
- package/dist/api/session-bye-options.d.ts +11 -0
- package/dist/api/session-delegate.d.ts +73 -0
- package/dist/api/session-description-handler-factory.d.ts +15 -0
- package/dist/api/session-description-handler.d.ts +74 -0
- package/dist/api/session-info-options.d.ts +11 -0
- package/dist/api/session-invite-options.d.ts +28 -0
- package/dist/api/session-message-options.d.ts +11 -0
- package/dist/api/session-options.d.ts +8 -0
- package/dist/api/session-refer-options.d.ts +14 -0
- package/dist/api/session-state.d.ts +45 -0
- package/dist/api/session.d.ts +359 -0
- package/dist/api/subscriber-options.d.ts +11 -0
- package/dist/api/subscriber-subscribe-options.d.ts +6 -0
- package/dist/api/subscriber.d.ts +94 -0
- package/dist/api/subscription-delegate.d.ts +12 -0
- package/dist/api/subscription-options.d.ts +8 -0
- package/dist/api/subscription-state.d.ts +19 -0
- package/dist/api/subscription-subscribe-options.d.ts +6 -0
- package/dist/api/subscription-unsubscribe-options.d.ts +6 -0
- package/dist/api/subscription.d.ts +84 -0
- package/dist/api/transport-state.d.ts +37 -0
- package/dist/api/transport.d.ts +159 -0
- package/dist/api/user-agent-delegate.d.ts +84 -0
- package/dist/api/user-agent-options.d.ts +253 -0
- package/dist/api/user-agent-state.d.ts +14 -0
- package/dist/api/user-agent.d.ts +200 -0
- package/dist/core/dialogs/dialog-state.d.ts +34 -0
- package/dist/core/dialogs/dialog.d.ts +161 -0
- package/dist/core/dialogs/index.d.ts +4 -0
- package/dist/core/dialogs/session-dialog.d.ts +196 -0
- package/dist/core/dialogs/subscription-dialog.d.ts +120 -0
- package/dist/core/exceptions/exception.d.ts +8 -0
- package/dist/core/exceptions/index.d.ts +3 -0
- package/dist/core/exceptions/transaction-state-error.d.ts +8 -0
- package/dist/core/exceptions/transport-error.d.ts +8 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/log/index.d.ts +3 -0
- package/dist/core/log/levels.d.ts +10 -0
- package/dist/core/log/logger-factory.d.ts +21 -0
- package/dist/core/log/logger.d.ts +19 -0
- package/dist/core/messages/body.d.ts +64 -0
- package/dist/core/messages/digest-authentication.d.ts +51 -0
- package/dist/core/messages/incoming-message.d.ts +79 -0
- package/dist/core/messages/incoming-request-message.d.ts +10 -0
- package/dist/core/messages/incoming-request.d.ts +67 -0
- package/dist/core/messages/incoming-response-message.d.ts +10 -0
- package/dist/core/messages/incoming-response.d.ts +12 -0
- package/dist/core/messages/index.d.ts +13 -0
- package/dist/core/messages/md5.d.ts +32 -0
- package/dist/core/messages/methods/ack.d.ts +18 -0
- package/dist/core/messages/methods/bye.d.ts +21 -0
- package/dist/core/messages/methods/cancel.d.ts +21 -0
- package/dist/core/messages/methods/constants.d.ts +20 -0
- package/dist/core/messages/methods/index.d.ts +13 -0
- package/dist/core/messages/methods/info.d.ts +21 -0
- package/dist/core/messages/methods/invite.d.ts +86 -0
- package/dist/core/messages/methods/message.d.ts +21 -0
- package/dist/core/messages/methods/notify.d.ts +21 -0
- package/dist/core/messages/methods/prack.d.ts +21 -0
- package/dist/core/messages/methods/publish.d.ts +21 -0
- package/dist/core/messages/methods/refer.d.ts +21 -0
- package/dist/core/messages/methods/register.d.ts +21 -0
- package/dist/core/messages/methods/subscribe.d.ts +54 -0
- package/dist/core/messages/outgoing-request-message.d.ts +94 -0
- package/dist/core/messages/outgoing-request.d.ts +67 -0
- package/dist/core/messages/outgoing-response.d.ts +42 -0
- package/dist/core/messages/parser.d.ts +14 -0
- package/dist/core/messages/utils.d.ts +24 -0
- package/dist/core/session/index.d.ts +2 -0
- package/dist/core/session/session-delegate.d.ts +70 -0
- package/dist/core/session/session.d.ts +134 -0
- package/dist/core/subscription/index.d.ts +2 -0
- package/dist/core/subscription/subscription-delegate.d.ts +27 -0
- package/dist/core/subscription/subscription.d.ts +55 -0
- package/dist/core/timers.d.ts +20 -0
- package/dist/core/transactions/client-transaction.d.ts +45 -0
- package/dist/core/transactions/index.d.ts +10 -0
- package/dist/core/transactions/invite-client-transaction.d.ts +116 -0
- package/dist/core/transactions/invite-server-transaction.d.ts +127 -0
- package/dist/core/transactions/non-invite-client-transaction.d.ts +69 -0
- package/dist/core/transactions/non-invite-server-transaction.d.ts +57 -0
- package/dist/core/transactions/server-transaction.d.ts +35 -0
- package/dist/core/transactions/transaction-state.d.ts +13 -0
- package/dist/core/transactions/transaction-user.d.ts +72 -0
- package/dist/core/transactions/transaction.d.ts +79 -0
- package/dist/core/transport.d.ts +31 -0
- package/dist/core/user-agent-core/allowed-methods.d.ts +4 -0
- package/dist/core/user-agent-core/index.d.ts +3 -0
- package/dist/core/user-agent-core/user-agent-core-configuration.d.ts +99 -0
- package/dist/core/user-agent-core/user-agent-core-delegate.d.ts +37 -0
- package/dist/core/user-agent-core/user-agent-core.d.ts +179 -0
- package/dist/core/user-agents/bye-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/bye-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/cancel-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/index.d.ts +26 -0
- package/dist/core/user-agents/info-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/info-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/invite-user-agent-client.d.ts +35 -0
- package/dist/core/user-agents/invite-user-agent-server.d.ts +77 -0
- package/dist/core/user-agents/message-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/message-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/notify-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/notify-user-agent-server.d.ts +16 -0
- package/dist/core/user-agents/prack-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/prack-user-agent-server.d.ts +16 -0
- package/dist/core/user-agents/publish-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/re-invite-user-agent-client.d.ts +18 -0
- package/dist/core/user-agents/re-invite-user-agent-server.d.ts +41 -0
- package/dist/core/user-agents/re-subscribe-user-agent-client.d.ts +17 -0
- package/dist/core/user-agents/re-subscribe-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/refer-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/refer-user-agent-server.d.ts +16 -0
- package/dist/core/user-agents/register-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/register-user-agent-server.d.ts +11 -0
- package/dist/core/user-agents/subscribe-user-agent-client.d.ts +65 -0
- package/dist/core/user-agents/subscribe-user-agent-server.d.ts +11 -0
- package/dist/core/user-agents/user-agent-client.d.ts +103 -0
- package/dist/core/user-agents/user-agent-server.d.ts +79 -0
- package/dist/grammar/grammar.d.ts +26 -0
- package/dist/grammar/index.d.ts +4 -0
- package/dist/grammar/name-addr-header.d.ts +24 -0
- package/dist/grammar/parameters.d.ts +16 -0
- package/dist/grammar/pegjs/dist/grammar.d.ts +50 -0
- package/dist/grammar/uri.d.ts +62 -0
- package/dist/{types/index.d.ts → index.d.ts} +7 -3
- package/dist/main.d.ts +9 -0
- package/dist/new-index.d.ts +199 -0
- package/dist/platform/web/index.d.ts +4 -0
- package/dist/platform/web/modifiers/index.d.ts +5 -0
- package/dist/platform/web/modifiers/modifiers.d.ts +41 -0
- package/dist/platform/web/session-description-handler/index.d.ts +14 -0
- package/dist/platform/web/session-description-handler/media-stream-factory-default.d.ts +6 -0
- package/dist/platform/web/session-description-handler/media-stream-factory.d.ts +6 -0
- package/dist/platform/web/session-description-handler/peer-connection-configuration-default.d.ts +5 -0
- package/dist/platform/web/session-description-handler/peer-connection-delegate.d.ts +63 -0
- package/dist/platform/web/session-description-handler/session-description-handler-configuration.d.ts +16 -0
- package/dist/platform/web/session-description-handler/session-description-handler-factory-default.d.ts +11 -0
- package/dist/platform/web/session-description-handler/session-description-handler-factory-options.d.ts +9 -0
- package/dist/platform/web/session-description-handler/session-description-handler-factory.d.ts +16 -0
- package/dist/platform/web/session-description-handler/session-description-handler-options.d.ts +47 -0
- package/dist/platform/web/session-description-handler/session-description-handler.d.ts +212 -0
- package/dist/platform/web/simple-user/index.d.ts +7 -0
- package/dist/platform/web/simple-user/simple-user-delegate.d.ts +72 -0
- package/dist/platform/web/simple-user/simple-user-options.d.ts +90 -0
- package/dist/platform/web/simple-user/simple-user.d.ts +226 -0
- package/dist/platform/web/transport/index.d.ts +6 -0
- package/dist/platform/web/transport/transport-options.d.ts +30 -0
- package/dist/platform/web/transport/transport.d.ts +125 -0
- package/dist/ue-softphone-sdk.js +2 -1
- package/dist/ue-softphone-sdk.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/webPhoneSdk.d.ts +24 -0
- package/dist/webrtc.d.ts +17 -0
- package/{rollup-new.config.mjs → new-rollup.config.mjs} +1 -1
- package/package.json +6 -6
- package/rollup.config.js +15 -14
- package/src/api/api-extractor.json +358 -0
- package/src/api/bye.ts +27 -0
- package/src/api/dtmf.ts +27 -0
- package/src/api/emitter.ts +110 -0
- package/src/api/exceptions/content-type-unsupported.ts +11 -0
- package/src/api/exceptions/index.ts +5 -0
- package/src/api/exceptions/request-pending.ts +12 -0
- package/src/api/exceptions/session-description-handler.ts +11 -0
- package/src/api/exceptions/session-terminated.ts +11 -0
- package/src/api/exceptions/state-transition.ts +11 -0
- package/src/api/index.ts +58 -0
- package/src/api/info.ts +27 -0
- package/src/api/invitation-accept-options.ts +20 -0
- package/src/api/invitation-progress-options.ts +36 -0
- package/src/api/invitation-reject-options.ts +22 -0
- package/src/api/invitation.ts +816 -0
- package/src/api/inviter-cancel-options.ts +9 -0
- package/src/api/inviter-invite-options.ts +29 -0
- package/src/api/inviter-options.ts +44 -0
- package/src/api/inviter.ts +1126 -0
- package/src/api/message.ts +27 -0
- package/src/api/messager-message-options.ts +12 -0
- package/src/api/messager-options.ts +18 -0
- package/src/api/messager.ts +89 -0
- package/src/api/notification.ts +27 -0
- package/src/api/notifier.ts +7 -0
- package/src/api/publisher-options.ts +34 -0
- package/src/api/publisher-publish-options.ts +6 -0
- package/src/api/publisher-state.ts +21 -0
- package/src/api/publisher-unpublish-options.ts +6 -0
- package/src/api/publisher.ts +418 -0
- package/src/api/referral.ts +89 -0
- package/src/api/registerer-options.ts +55 -0
- package/src/api/registerer-register-options.ts +12 -0
- package/src/api/registerer-state.ts +21 -0
- package/src/api/registerer-unregister-options.ts +17 -0
- package/src/api/registerer.ts +814 -0
- package/src/api/session-bye-options.ts +12 -0
- package/src/api/session-delegate.ts +80 -0
- package/src/api/session-description-handler-factory.ts +16 -0
- package/src/api/session-description-handler.ts +89 -0
- package/src/api/session-info-options.ts +12 -0
- package/src/api/session-invite-options.ts +29 -0
- package/src/api/session-message-options.ts +12 -0
- package/src/api/session-options.ts +8 -0
- package/src/api/session-refer-options.ts +15 -0
- package/src/api/session-state.ts +45 -0
- package/src/api/session.ts +1448 -0
- package/src/api/subscriber-options.ts +12 -0
- package/src/api/subscriber-subscribe-options.ts +6 -0
- package/src/api/subscriber.ts +536 -0
- package/src/api/subscription-delegate.ts +13 -0
- package/src/api/subscription-options.ts +8 -0
- package/src/api/subscription-state.ts +19 -0
- package/src/api/subscription-subscribe-options.ts +6 -0
- package/src/api/subscription-unsubscribe-options.ts +6 -0
- package/src/api/subscription.ts +161 -0
- package/src/api/transport-state.ts +37 -0
- package/src/api/transport.ts +169 -0
- package/src/api/user-agent-delegate.ts +95 -0
- package/src/api/user-agent-options.ts +322 -0
- package/src/api/user-agent-state.ts +14 -0
- package/src/api/user-agent.ts +1014 -0
- package/src/core/api-extractor.json +358 -0
- package/src/core/dialogs/dialog-state.ts +35 -0
- package/src/core/dialogs/dialog.ts +605 -0
- package/src/core/dialogs/index.ts +4 -0
- package/src/core/dialogs/session-dialog.ts +996 -0
- package/src/core/dialogs/subscription-dialog.ts +557 -0
- package/src/core/exceptions/exception.ts +11 -0
- package/src/core/exceptions/index.ts +3 -0
- package/src/core/exceptions/transaction-state-error.ts +11 -0
- package/src/core/exceptions/transport-error.ts +11 -0
- package/src/core/index.ts +19 -0
- package/src/core/log/index.ts +3 -0
- package/src/core/log/levels.ts +10 -0
- package/src/core/log/logger-factory.ts +119 -0
- package/src/core/log/logger.ts +42 -0
- package/src/core/messages/body.ts +171 -0
- package/src/core/messages/digest-authentication.ts +190 -0
- package/src/core/messages/incoming-message.ts +152 -0
- package/src/core/messages/incoming-request-message.ts +14 -0
- package/src/core/messages/incoming-request.ts +75 -0
- package/src/core/messages/incoming-response-message.ts +14 -0
- package/src/core/messages/incoming-response.ts +13 -0
- package/src/core/messages/index.ts +18 -0
- package/src/core/messages/md5.ts +437 -0
- package/src/core/messages/methods/ack.ts +22 -0
- package/src/core/messages/methods/bye.ts +22 -0
- package/src/core/messages/methods/cancel.ts +22 -0
- package/src/core/messages/methods/constants.ts +21 -0
- package/src/core/messages/methods/index.ts +13 -0
- package/src/core/messages/methods/info.ts +22 -0
- package/src/core/messages/methods/invite.ts +104 -0
- package/src/core/messages/methods/message.ts +22 -0
- package/src/core/messages/methods/notify.ts +22 -0
- package/src/core/messages/methods/prack.ts +22 -0
- package/src/core/messages/methods/publish.ts +22 -0
- package/src/core/messages/methods/refer.ts +22 -0
- package/src/core/messages/methods/register.ts +22 -0
- package/src/core/messages/methods/subscribe.ts +59 -0
- package/src/core/messages/outgoing-request-message.ts +299 -0
- package/src/core/messages/outgoing-request.ts +77 -0
- package/src/core/messages/outgoing-response.ts +174 -0
- package/src/core/messages/parser.ts +265 -0
- package/src/core/messages/utils.ts +144 -0
- package/src/core/session/index.ts +2 -0
- package/src/core/session/session-delegate.ts +88 -0
- package/src/core/session/session.ts +158 -0
- package/src/core/subscription/index.ts +2 -0
- package/src/core/subscription/subscription-delegate.ts +30 -0
- package/src/core/subscription/subscription.ts +61 -0
- package/src/core/timers.ts +24 -0
- package/src/core/transactions/client-transaction.ts +78 -0
- package/src/core/transactions/index.ts +10 -0
- package/src/core/transactions/invite-client-transaction.ts +504 -0
- package/src/core/transactions/invite-server-transaction.ts +432 -0
- package/src/core/transactions/non-invite-client-transaction.ts +257 -0
- package/src/core/transactions/non-invite-server-transaction.ts +241 -0
- package/src/core/transactions/server-transaction.ts +47 -0
- package/src/core/transactions/transaction-state.ts +13 -0
- package/src/core/transactions/transaction-user.ts +82 -0
- package/src/core/transactions/transaction.ts +149 -0
- package/src/core/transport.ts +32 -0
- package/src/core/user-agent-core/allowed-methods.ts +19 -0
- package/src/core/user-agent-core/index.ts +3 -0
- package/src/core/user-agent-core/user-agent-core-configuration.ts +111 -0
- package/src/core/user-agent-core/user-agent-core-delegate.ts +50 -0
- package/src/core/user-agent-core/user-agent-core.ts +905 -0
- package/src/core/user-agents/bye-user-agent-client.ts +16 -0
- package/src/core/user-agents/bye-user-agent-server.ts +14 -0
- package/src/core/user-agents/cancel-user-agent-client.ts +14 -0
- package/src/core/user-agents/index.ts +26 -0
- package/src/core/user-agents/info-user-agent-client.ts +15 -0
- package/src/core/user-agents/info-user-agent-server.ts +14 -0
- package/src/core/user-agents/invite-user-agent-client.ts +405 -0
- package/src/core/user-agents/invite-user-agent-server.ts +269 -0
- package/src/core/user-agents/message-user-agent-client.ts +14 -0
- package/src/core/user-agents/message-user-agent-server.ts +14 -0
- package/src/core/user-agents/notify-user-agent-client.ts +15 -0
- package/src/core/user-agents/notify-user-agent-server.ts +30 -0
- package/src/core/user-agents/prack-user-agent-client.ts +16 -0
- package/src/core/user-agents/prack-user-agent-server.ts +37 -0
- package/src/core/user-agents/publish-user-agent-client.ts +14 -0
- package/src/core/user-agents/re-invite-user-agent-client.ts +127 -0
- package/src/core/user-agents/re-invite-user-agent-server.ts +109 -0
- package/src/core/user-agents/re-subscribe-user-agent-client.ts +78 -0
- package/src/core/user-agents/re-subscribe-user-agent-server.ts +14 -0
- package/src/core/user-agents/refer-user-agent-client.ts +15 -0
- package/src/core/user-agents/refer-user-agent-server.ts +30 -0
- package/src/core/user-agents/register-user-agent-client.ts +14 -0
- package/src/core/user-agents/register-user-agent-server.ts +14 -0
- package/src/core/user-agents/subscribe-user-agent-client.ts +341 -0
- package/src/core/user-agents/subscribe-user-agent-server.ts +14 -0
- package/src/core/user-agents/user-agent-client.ts +378 -0
- package/src/core/user-agents/user-agent-server.ts +276 -0
- package/src/grammar/grammar.ts +55 -0
- package/src/grammar/index.ts +4 -0
- package/src/grammar/name-addr-header.ts +58 -0
- package/src/grammar/parameters.ts +45 -0
- package/src/grammar/pegjs/README.md +9 -0
- package/src/grammar/pegjs/dist/grammar.ts +1557 -0
- package/src/grammar/pegjs/src/grammar.pegjs +1009 -0
- package/src/grammar/uri.ts +370 -0
- package/src/index.ts +59 -28
- package/src/lib/socket.io.esm.min.js +7 -0
- package/src/main.ts +26 -0
- package/src/new-index.ts +2478 -0
- package/src/platform/react/README.md +1 -0
- package/src/platform/web/index.ts +4 -0
- package/src/platform/web/modifiers/index.ts +5 -0
- package/src/platform/web/modifiers/modifiers.ts +180 -0
- package/src/platform/web/session-description-handler/api-extractor.json +358 -0
- package/src/platform/web/session-description-handler/index.ts +14 -0
- package/src/platform/web/session-description-handler/media-stream-factory-default.ts +22 -0
- package/src/platform/web/session-description-handler/media-stream-factory.ts +10 -0
- package/src/platform/web/session-description-handler/peer-connection-configuration-default.ts +17 -0
- package/src/platform/web/session-description-handler/peer-connection-delegate.ts +72 -0
- package/src/platform/web/session-description-handler/session-description-handler-configuration.ts +17 -0
- package/src/platform/web/session-description-handler/session-description-handler-factory-default.ts +45 -0
- package/src/platform/web/session-description-handler/session-description-handler-factory-options.ts +10 -0
- package/src/platform/web/session-description-handler/session-description-handler-factory.ts +17 -0
- package/src/platform/web/session-description-handler/session-description-handler-options.ts +56 -0
- package/src/platform/web/session-description-handler/session-description-handler.ts +938 -0
- package/src/platform/web/simple-user/api-extractor.json +358 -0
- package/src/platform/web/simple-user/index.ts +7 -0
- package/src/platform/web/simple-user/simple-user-delegate.ts +82 -0
- package/src/platform/web/simple-user/simple-user-options.ts +102 -0
- package/src/platform/web/simple-user/simple-user.ts +1099 -0
- package/src/platform/web/transport/api-extractor.json +358 -0
- package/src/platform/web/transport/index.ts +6 -0
- package/src/platform/web/transport/transport-options.ts +34 -0
- package/src/platform/web/transport/transport.ts +742 -0
- package/src/version.ts +8 -0
- package/src/webPhoneSdk.ts +67 -0
- package/src/webrtc.ts +318 -0
- package/tsconfig.json +26 -10
- /package/dist/{types/config.d.ts → config.d.ts} +0 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { TransportError } from "../exceptions";
|
|
2
|
+
import { C, IncomingRequestMessage } from "../messages";
|
|
3
|
+
import { Timers } from "../timers";
|
|
4
|
+
import { Transport } from "../transport";
|
|
5
|
+
import { ServerTransaction } from "./server-transaction";
|
|
6
|
+
import { TransactionState } from "./transaction-state";
|
|
7
|
+
import { ServerTransactionUser } from "./transaction-user";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* INVITE Server Transaction.
|
|
11
|
+
* @remarks
|
|
12
|
+
* https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export class InviteServerTransaction extends ServerTransaction {
|
|
16
|
+
private lastFinalResponse: string | undefined;
|
|
17
|
+
private lastProvisionalResponse: string | undefined;
|
|
18
|
+
private H: number | undefined;
|
|
19
|
+
private I: number | undefined;
|
|
20
|
+
private L: number | undefined;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* FIXME: This should not be here. It should be in the UAS.
|
|
24
|
+
*
|
|
25
|
+
* If the UAS desires an extended period of time to answer the INVITE,
|
|
26
|
+
* it will need to ask for an "extension" in order to prevent proxies
|
|
27
|
+
* from canceling the transaction. A proxy has the option of canceling
|
|
28
|
+
* a transaction when there is a gap of 3 minutes between responses in a
|
|
29
|
+
* transaction. To prevent cancellation, the UAS MUST send a non-100
|
|
30
|
+
* provisional response at every minute, to handle the possibility of
|
|
31
|
+
* lost provisional responses.
|
|
32
|
+
*
|
|
33
|
+
* An INVITE transaction can go on for extended durations when the
|
|
34
|
+
* user is placed on hold, or when interworking with PSTN systems
|
|
35
|
+
* which allow communications to take place without answering the
|
|
36
|
+
* call. The latter is common in Interactive Voice Response (IVR)
|
|
37
|
+
* systems.
|
|
38
|
+
* https://tools.ietf.org/html/rfc3261#section-13.3.1.1
|
|
39
|
+
*/
|
|
40
|
+
private progressExtensionTimer: number | undefined;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Constructor.
|
|
44
|
+
* Upon construction, a "100 Trying" reply will be immediately sent.
|
|
45
|
+
* After construction the transaction will be in the "proceeding" state and the transaction
|
|
46
|
+
* `id` will equal the branch parameter set in the Via header of the incoming request.
|
|
47
|
+
* https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
48
|
+
* @param request - Incoming INVITE request from the transport.
|
|
49
|
+
* @param transport - The transport.
|
|
50
|
+
* @param user - The transaction user.
|
|
51
|
+
*/
|
|
52
|
+
constructor(request: IncomingRequestMessage, transport: Transport, user: ServerTransactionUser) {
|
|
53
|
+
super(request, transport, user, TransactionState.Proceeding, "sip.transaction.ist");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Destructor.
|
|
58
|
+
*/
|
|
59
|
+
public dispose(): void {
|
|
60
|
+
this.stopProgressExtensionTimer();
|
|
61
|
+
if (this.H) {
|
|
62
|
+
clearTimeout(this.H);
|
|
63
|
+
this.H = undefined;
|
|
64
|
+
}
|
|
65
|
+
if (this.I) {
|
|
66
|
+
clearTimeout(this.I);
|
|
67
|
+
this.I = undefined;
|
|
68
|
+
}
|
|
69
|
+
if (this.L) {
|
|
70
|
+
clearTimeout(this.L);
|
|
71
|
+
this.L = undefined;
|
|
72
|
+
}
|
|
73
|
+
super.dispose();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Transaction kind. Deprecated. */
|
|
77
|
+
get kind(): string {
|
|
78
|
+
return "ist";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Receive requests from transport matching this transaction.
|
|
83
|
+
* @param request - Request matching this transaction.
|
|
84
|
+
*/
|
|
85
|
+
public receiveRequest(request: IncomingRequestMessage): void {
|
|
86
|
+
switch (this.state) {
|
|
87
|
+
case TransactionState.Proceeding:
|
|
88
|
+
// If a request retransmission is received while in the "Proceeding" state, the most
|
|
89
|
+
// recent provisional response that was received from the TU MUST be passed to the
|
|
90
|
+
// transport layer for retransmission.
|
|
91
|
+
// https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
92
|
+
if (request.method === C.INVITE) {
|
|
93
|
+
if (this.lastProvisionalResponse) {
|
|
94
|
+
this.send(this.lastProvisionalResponse).catch((error: TransportError) => {
|
|
95
|
+
this.logTransportError(error, "Failed to send retransmission of provisional response.");
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case TransactionState.Accepted:
|
|
102
|
+
// While in the "Accepted" state, any retransmissions of the INVITE
|
|
103
|
+
// received will match this transaction state machine and will be
|
|
104
|
+
// absorbed by the machine without changing its state. These
|
|
105
|
+
// retransmissions are not passed onto the TU.
|
|
106
|
+
// https://tools.ietf.org/html/rfc6026#section-7.1
|
|
107
|
+
if (request.method === C.INVITE) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case TransactionState.Completed:
|
|
112
|
+
// Furthermore, while in the "Completed" state, if a request retransmission is
|
|
113
|
+
// received, the server SHOULD pass the response to the transport for retransmission.
|
|
114
|
+
// https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
115
|
+
if (request.method === C.INVITE) {
|
|
116
|
+
if (!this.lastFinalResponse) {
|
|
117
|
+
throw new Error("Last final response undefined.");
|
|
118
|
+
}
|
|
119
|
+
this.send(this.lastFinalResponse).catch((error: TransportError) => {
|
|
120
|
+
this.logTransportError(error, "Failed to send retransmission of final response.");
|
|
121
|
+
});
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// If an ACK is received while the server transaction is in the "Completed" state,
|
|
125
|
+
// the server transaction MUST transition to the "Confirmed" state.
|
|
126
|
+
// https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
127
|
+
if (request.method === C.ACK) {
|
|
128
|
+
this.stateTransition(TransactionState.Confirmed);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
case TransactionState.Confirmed:
|
|
133
|
+
// The purpose of the "Confirmed" state is to absorb any additional ACK messages that arrive,
|
|
134
|
+
// triggered from retransmissions of the final response.
|
|
135
|
+
// https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
136
|
+
if (request.method === C.INVITE || request.method === C.ACK) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
case TransactionState.Terminated:
|
|
141
|
+
// For good measure absorb any additional messages that arrive (should not happen).
|
|
142
|
+
if (request.method === C.INVITE || request.method === C.ACK) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
default:
|
|
147
|
+
throw new Error(`Invalid state ${this.state}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const message = `INVITE server transaction received unexpected ${request.method} request while in state ${this.state}.`;
|
|
151
|
+
this.logger.warn(message);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Receive responses from TU for this transaction.
|
|
157
|
+
* @param statusCode - Status code of response.
|
|
158
|
+
* @param response - Response.
|
|
159
|
+
*/
|
|
160
|
+
public receiveResponse(statusCode: number, response: string): void {
|
|
161
|
+
if (statusCode < 100 || statusCode > 699) {
|
|
162
|
+
throw new Error(`Invalid status code ${statusCode}`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
switch (this.state) {
|
|
166
|
+
case TransactionState.Proceeding:
|
|
167
|
+
// The TU passes any number of provisional responses to the server
|
|
168
|
+
// transaction. So long as the server transaction is in the
|
|
169
|
+
// "Proceeding" state, each of these MUST be passed to the transport
|
|
170
|
+
// layer for transmission. They are not sent reliably by the
|
|
171
|
+
// transaction layer (they are not retransmitted by it) and do not cause
|
|
172
|
+
// a change in the state of the server transaction.
|
|
173
|
+
// https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
174
|
+
if (statusCode >= 100 && statusCode <= 199) {
|
|
175
|
+
this.lastProvisionalResponse = response;
|
|
176
|
+
// Start the progress extension timer only for a non-100 provisional response.
|
|
177
|
+
if (statusCode > 100) {
|
|
178
|
+
this.startProgressExtensionTimer(); // FIXME: remove
|
|
179
|
+
}
|
|
180
|
+
this.send(response).catch((error: TransportError) => {
|
|
181
|
+
this.logTransportError(error, "Failed to send 1xx response.");
|
|
182
|
+
});
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// If, while in the "Proceeding" state, the TU passes a 2xx response
|
|
186
|
+
// to the server transaction, the server transaction MUST pass this
|
|
187
|
+
// response to the transport layer for transmission. It is not
|
|
188
|
+
// retransmitted by the server transaction; retransmissions of 2xx
|
|
189
|
+
// responses are handled by the TU. The server transaction MUST then
|
|
190
|
+
// transition to the "Accepted" state.
|
|
191
|
+
// https://tools.ietf.org/html/rfc6026#section-8.5
|
|
192
|
+
if (statusCode >= 200 && statusCode <= 299) {
|
|
193
|
+
this.lastFinalResponse = response;
|
|
194
|
+
this.stateTransition(TransactionState.Accepted);
|
|
195
|
+
this.send(response).catch((error: TransportError) => {
|
|
196
|
+
this.logTransportError(error, "Failed to send 2xx response.");
|
|
197
|
+
});
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// While in the "Proceeding" state, if the TU passes a response with
|
|
201
|
+
// status code from 300 to 699 to the server transaction, the response
|
|
202
|
+
// MUST be passed to the transport layer for transmission, and the state
|
|
203
|
+
// machine MUST enter the "Completed" state.
|
|
204
|
+
// https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
205
|
+
if (statusCode >= 300 && statusCode <= 699) {
|
|
206
|
+
this.lastFinalResponse = response;
|
|
207
|
+
this.stateTransition(TransactionState.Completed);
|
|
208
|
+
this.send(response).catch((error: TransportError) => {
|
|
209
|
+
this.logTransportError(error, "Failed to send non-2xx final response.");
|
|
210
|
+
});
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
break;
|
|
214
|
+
case TransactionState.Accepted:
|
|
215
|
+
// While in the "Accepted" state, if the TU passes a 2xx response,
|
|
216
|
+
// the server transaction MUST pass the response to the transport layer for transmission.
|
|
217
|
+
// https://tools.ietf.org/html/rfc6026#section-8.7
|
|
218
|
+
if (statusCode >= 200 && statusCode <= 299) {
|
|
219
|
+
this.send(response).catch((error: TransportError) => {
|
|
220
|
+
this.logTransportError(error, "Failed to send 2xx response.");
|
|
221
|
+
});
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case TransactionState.Completed:
|
|
226
|
+
break;
|
|
227
|
+
case TransactionState.Confirmed:
|
|
228
|
+
break;
|
|
229
|
+
case TransactionState.Terminated:
|
|
230
|
+
break;
|
|
231
|
+
default:
|
|
232
|
+
throw new Error(`Invalid state ${this.state}`);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const message = `INVITE server transaction received unexpected ${statusCode} response from TU while in state ${this.state}.`;
|
|
236
|
+
this.logger.error(message);
|
|
237
|
+
throw new Error(message);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Retransmit the last 2xx response. This is a noop if not in the "accepted" state.
|
|
242
|
+
*/
|
|
243
|
+
public retransmitAcceptedResponse(): void {
|
|
244
|
+
if (this.state === TransactionState.Accepted && this.lastFinalResponse) {
|
|
245
|
+
this.send(this.lastFinalResponse).catch((error: TransportError) => {
|
|
246
|
+
this.logTransportError(error, "Failed to send 2xx response.");
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* First, the procedures in [4] are followed, which attempt to deliver the response to a backup.
|
|
253
|
+
* If those should all fail, based on the definition of failure in [4], the server transaction SHOULD
|
|
254
|
+
* inform the TU that a failure has occurred, and MUST remain in the current state.
|
|
255
|
+
* https://tools.ietf.org/html/rfc6026#section-8.8
|
|
256
|
+
*/
|
|
257
|
+
protected onTransportError(error: Error): void {
|
|
258
|
+
if (this.user.onTransportError) {
|
|
259
|
+
this.user.onTransportError(error);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** For logging. */
|
|
264
|
+
protected typeToString(): string {
|
|
265
|
+
return "INVITE server transaction";
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Execute a state transition.
|
|
270
|
+
* @param newState - New state.
|
|
271
|
+
*/
|
|
272
|
+
private stateTransition(newState: TransactionState): void {
|
|
273
|
+
// Assert valid state transitions.
|
|
274
|
+
const invalidStateTransition = (): void => {
|
|
275
|
+
throw new Error(`Invalid state transition from ${this.state} to ${newState}`);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
switch (newState) {
|
|
279
|
+
case TransactionState.Proceeding:
|
|
280
|
+
invalidStateTransition();
|
|
281
|
+
break;
|
|
282
|
+
case TransactionState.Accepted:
|
|
283
|
+
case TransactionState.Completed:
|
|
284
|
+
if (this.state !== TransactionState.Proceeding) {
|
|
285
|
+
invalidStateTransition();
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
288
|
+
case TransactionState.Confirmed:
|
|
289
|
+
if (this.state !== TransactionState.Completed) {
|
|
290
|
+
invalidStateTransition();
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
case TransactionState.Terminated:
|
|
294
|
+
if (
|
|
295
|
+
this.state !== TransactionState.Accepted &&
|
|
296
|
+
this.state !== TransactionState.Completed &&
|
|
297
|
+
this.state !== TransactionState.Confirmed
|
|
298
|
+
) {
|
|
299
|
+
invalidStateTransition();
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
default:
|
|
303
|
+
invalidStateTransition();
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// On any state transition, stop resending provisional responses
|
|
307
|
+
this.stopProgressExtensionTimer();
|
|
308
|
+
|
|
309
|
+
// The purpose of the "Accepted" state is to absorb retransmissions of an accepted INVITE request.
|
|
310
|
+
// Any such retransmissions are absorbed entirely within the server transaction.
|
|
311
|
+
// They are not passed up to the TU since any downstream UAS cores that accepted the request have
|
|
312
|
+
// taken responsibility for reliability and will already retransmit their 2xx responses if necessary.
|
|
313
|
+
// https://tools.ietf.org/html/rfc6026#section-8.7
|
|
314
|
+
if (newState === TransactionState.Accepted) {
|
|
315
|
+
this.L = window.setTimeout(() => this.timerL(), Timers.TIMER_L);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// When the "Completed" state is entered, timer H MUST be set to fire in 64*T1 seconds for all transports.
|
|
319
|
+
// Timer H determines when the server transaction abandons retransmitting the response.
|
|
320
|
+
// If an ACK is received while the server transaction is in the "Completed" state,
|
|
321
|
+
// the server transaction MUST transition to the "Confirmed" state.
|
|
322
|
+
// https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
323
|
+
if (newState === TransactionState.Completed) {
|
|
324
|
+
// FIXME: Missing timer G for unreliable transports.
|
|
325
|
+
this.H = window.setTimeout(() => this.timerH(), Timers.TIMER_H);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// The purpose of the "Confirmed" state is to absorb any additional ACK messages that arrive,
|
|
329
|
+
// triggered from retransmissions of the final response. When this state is entered, timer I
|
|
330
|
+
// is set to fire in T4 seconds for unreliable transports, and zero seconds for reliable
|
|
331
|
+
// transports. Once timer I fires, the server MUST transition to the "Terminated" state.
|
|
332
|
+
// https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
333
|
+
if (newState === TransactionState.Confirmed) {
|
|
334
|
+
// FIXME: This timer is not getting set correctly for unreliable transports.
|
|
335
|
+
this.I = window.setTimeout(() => this.timerI(), Timers.TIMER_I);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Once the transaction is in the "Terminated" state, it MUST be destroyed immediately.
|
|
339
|
+
// https://tools.ietf.org/html/rfc6026#section-8.7
|
|
340
|
+
if (newState === TransactionState.Terminated) {
|
|
341
|
+
this.dispose();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Update state.
|
|
345
|
+
this.setState(newState);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* FIXME: UAS Provisional Retransmission Timer. See RFC 3261 Section 13.3.1.1
|
|
350
|
+
* This is in the wrong place. This is not a transaction level thing. It's a UAS level thing.
|
|
351
|
+
*/
|
|
352
|
+
private startProgressExtensionTimer(): void {
|
|
353
|
+
// Start the progress extension timer only for the first non-100 provisional response.
|
|
354
|
+
if (this.progressExtensionTimer === undefined) {
|
|
355
|
+
this.progressExtensionTimer = window.setInterval(() => {
|
|
356
|
+
this.logger.debug(`Progress extension timer expired for INVITE server transaction ${this.id}.`);
|
|
357
|
+
if (!this.lastProvisionalResponse) {
|
|
358
|
+
throw new Error("Last provisional response undefined.");
|
|
359
|
+
}
|
|
360
|
+
this.send(this.lastProvisionalResponse).catch((error: TransportError) => {
|
|
361
|
+
this.logTransportError(error, "Failed to send retransmission of provisional response.");
|
|
362
|
+
});
|
|
363
|
+
}, Timers.PROVISIONAL_RESPONSE_INTERVAL);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* FIXME: UAS Provisional Retransmission Timer id. See RFC 3261 Section 13.3.1.1
|
|
369
|
+
* This is in the wrong place. This is not a transaction level thing. It's a UAS level thing.
|
|
370
|
+
*/
|
|
371
|
+
private stopProgressExtensionTimer(): void {
|
|
372
|
+
if (this.progressExtensionTimer !== undefined) {
|
|
373
|
+
clearInterval(this.progressExtensionTimer);
|
|
374
|
+
this.progressExtensionTimer = undefined;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* While in the "Proceeding" state, if the TU passes a response with status code
|
|
380
|
+
* from 300 to 699 to the server transaction, the response MUST be passed to the
|
|
381
|
+
* transport layer for transmission, and the state machine MUST enter the "Completed" state.
|
|
382
|
+
* For unreliable transports, timer G is set to fire in T1 seconds, and is not set to fire for
|
|
383
|
+
* reliable transports. If timer G fires, the response is passed to the transport layer once
|
|
384
|
+
* more for retransmission, and timer G is set to fire in MIN(2*T1, T2) seconds. From then on,
|
|
385
|
+
* when timer G fires, the response is passed to the transport again for transmission, and
|
|
386
|
+
* timer G is reset with a value that doubles, unless that value exceeds T2, in which case
|
|
387
|
+
* it is reset with the value of T2.
|
|
388
|
+
* https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
389
|
+
*/
|
|
390
|
+
private timerG(): void {
|
|
391
|
+
// TODO
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* If timer H fires while in the "Completed" state, it implies that the ACK was never received.
|
|
396
|
+
* In this case, the server transaction MUST transition to the "Terminated" state, and MUST
|
|
397
|
+
* indicate to the TU that a transaction failure has occurred.
|
|
398
|
+
* https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
399
|
+
*/
|
|
400
|
+
private timerH(): void {
|
|
401
|
+
this.logger.debug(`Timer H expired for INVITE server transaction ${this.id}.`);
|
|
402
|
+
if (this.state === TransactionState.Completed) {
|
|
403
|
+
this.logger.warn("ACK to negative final response was never received, terminating transaction.");
|
|
404
|
+
this.stateTransition(TransactionState.Terminated);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Once timer I fires, the server MUST transition to the "Terminated" state.
|
|
410
|
+
* https://tools.ietf.org/html/rfc3261#section-17.2.1
|
|
411
|
+
*/
|
|
412
|
+
private timerI(): void {
|
|
413
|
+
this.logger.debug(`Timer I expired for INVITE server transaction ${this.id}.`);
|
|
414
|
+
this.stateTransition(TransactionState.Terminated);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* When Timer L fires and the state machine is in the "Accepted" state, the machine MUST
|
|
419
|
+
* transition to the "Terminated" state. Once the transaction is in the "Terminated" state,
|
|
420
|
+
* it MUST be destroyed immediately. Timer L reflects the amount of time the server
|
|
421
|
+
* transaction could receive 2xx responses for retransmission from the
|
|
422
|
+
* TU while it is waiting to receive an ACK.
|
|
423
|
+
* https://tools.ietf.org/html/rfc6026#section-7.1
|
|
424
|
+
* https://tools.ietf.org/html/rfc6026#section-8.7
|
|
425
|
+
*/
|
|
426
|
+
private timerL(): void {
|
|
427
|
+
this.logger.debug(`Timer L expired for INVITE server transaction ${this.id}.`);
|
|
428
|
+
if (this.state === TransactionState.Accepted) {
|
|
429
|
+
this.stateTransition(TransactionState.Terminated);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { TransportError } from "../exceptions";
|
|
2
|
+
import { IncomingResponseMessage, OutgoingRequestMessage } from "../messages";
|
|
3
|
+
import { Timers } from "../timers";
|
|
4
|
+
import { Transport } from "../transport";
|
|
5
|
+
import { ClientTransaction } from "./client-transaction";
|
|
6
|
+
import { TransactionState } from "./transaction-state";
|
|
7
|
+
import { ClientTransactionUser } from "./transaction-user";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Non-INVITE Client Transaction.
|
|
11
|
+
* @remarks
|
|
12
|
+
* Non-INVITE transactions do not make use of ACK.
|
|
13
|
+
* They are simple request-response interactions.
|
|
14
|
+
* https://tools.ietf.org/html/rfc3261#section-17.1.2
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export class NonInviteClientTransaction extends ClientTransaction {
|
|
18
|
+
private F: number | undefined;
|
|
19
|
+
private K: number | undefined;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Constructor
|
|
23
|
+
* Upon construction, the outgoing request's Via header is updated by calling `setViaHeader`.
|
|
24
|
+
* Then `toString` is called on the outgoing request and the message is sent via the transport.
|
|
25
|
+
* After construction the transaction will be in the "calling" state and the transaction id
|
|
26
|
+
* will equal the branch parameter set in the Via header of the outgoing request.
|
|
27
|
+
* https://tools.ietf.org/html/rfc3261#section-17.1.2
|
|
28
|
+
* @param request - The outgoing Non-INVITE request.
|
|
29
|
+
* @param transport - The transport.
|
|
30
|
+
* @param user - The transaction user.
|
|
31
|
+
*/
|
|
32
|
+
constructor(request: OutgoingRequestMessage, transport: Transport, user: ClientTransactionUser) {
|
|
33
|
+
super(request, transport, user, TransactionState.Trying, "sip.transaction.nict");
|
|
34
|
+
// FIXME: Timer E for unreliable transports not implemented.
|
|
35
|
+
//
|
|
36
|
+
// The "Trying" state is entered when the TU initiates a new client
|
|
37
|
+
// transaction with a request. When entering this state, the client
|
|
38
|
+
// transaction SHOULD set timer F to fire in 64*T1 seconds. The request
|
|
39
|
+
// MUST be passed to the transport layer for transmission.
|
|
40
|
+
// https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
41
|
+
this.F = window.setTimeout(() => this.timerF(), Timers.TIMER_F);
|
|
42
|
+
this.send(request.toString()).catch((error: TransportError) => {
|
|
43
|
+
this.logTransportError(error, "Failed to send initial outgoing request.");
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Destructor.
|
|
49
|
+
*/
|
|
50
|
+
public dispose(): void {
|
|
51
|
+
if (this.F) {
|
|
52
|
+
clearTimeout(this.F);
|
|
53
|
+
this.F = undefined;
|
|
54
|
+
}
|
|
55
|
+
if (this.K) {
|
|
56
|
+
clearTimeout(this.K);
|
|
57
|
+
this.K = undefined;
|
|
58
|
+
}
|
|
59
|
+
super.dispose();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Transaction kind. Deprecated. */
|
|
63
|
+
get kind(): string {
|
|
64
|
+
return "nict";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Handler for incoming responses from the transport which match this transaction.
|
|
69
|
+
* @param response - The incoming response.
|
|
70
|
+
*/
|
|
71
|
+
public receiveResponse(response: IncomingResponseMessage): void {
|
|
72
|
+
const statusCode = response.statusCode;
|
|
73
|
+
if (!statusCode || statusCode < 100 || statusCode > 699) {
|
|
74
|
+
throw new Error(`Invalid status code ${statusCode}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
switch (this.state) {
|
|
78
|
+
case TransactionState.Trying:
|
|
79
|
+
// If a provisional response is received while in the "Trying" state, the
|
|
80
|
+
// response MUST be passed to the TU, and then the client transaction
|
|
81
|
+
// SHOULD move to the "Proceeding" state.
|
|
82
|
+
// https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
83
|
+
if (statusCode >= 100 && statusCode <= 199) {
|
|
84
|
+
this.stateTransition(TransactionState.Proceeding);
|
|
85
|
+
if (this.user.receiveResponse) {
|
|
86
|
+
this.user.receiveResponse(response);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// If a final response (status codes 200-699) is received while in the
|
|
91
|
+
// "Trying" state, the response MUST be passed to the TU, and the
|
|
92
|
+
// client transaction MUST transition to the "Completed" state.
|
|
93
|
+
// https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
94
|
+
if (statusCode >= 200 && statusCode <= 699) {
|
|
95
|
+
this.stateTransition(TransactionState.Completed);
|
|
96
|
+
if (statusCode === 408) {
|
|
97
|
+
this.onRequestTimeout();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (this.user.receiveResponse) {
|
|
101
|
+
this.user.receiveResponse(response);
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
case TransactionState.Proceeding:
|
|
107
|
+
// If a provisional response is received while in the "Proceeding" state,
|
|
108
|
+
// the response MUST be passed to the TU. (From Figure 6)
|
|
109
|
+
// https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
110
|
+
if (statusCode >= 100 && statusCode <= 199) {
|
|
111
|
+
if (this.user.receiveResponse) {
|
|
112
|
+
return this.user.receiveResponse(response);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// If a final response (status codes 200-699) is received while in the
|
|
116
|
+
// "Proceeding" state, the response MUST be passed to the TU, and the
|
|
117
|
+
// client transaction MUST transition to the "Completed" state.
|
|
118
|
+
// https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
119
|
+
if (statusCode >= 200 && statusCode <= 699) {
|
|
120
|
+
this.stateTransition(TransactionState.Completed);
|
|
121
|
+
if (statusCode === 408) {
|
|
122
|
+
this.onRequestTimeout();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (this.user.receiveResponse) {
|
|
126
|
+
this.user.receiveResponse(response);
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
case TransactionState.Completed:
|
|
132
|
+
// The "Completed" state exists to buffer any additional response
|
|
133
|
+
// retransmissions that may be received (which is why the client
|
|
134
|
+
// transaction remains there only for unreliable transports).
|
|
135
|
+
// https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
136
|
+
return;
|
|
137
|
+
case TransactionState.Terminated:
|
|
138
|
+
// For good measure just absorb additional response retransmissions.
|
|
139
|
+
return;
|
|
140
|
+
default:
|
|
141
|
+
throw new Error(`Invalid state ${this.state}`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const message = `Non-INVITE client transaction received unexpected ${statusCode} response while in state ${this.state}.`;
|
|
145
|
+
this.logger.warn(message);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The client transaction SHOULD inform the TU that a transport failure has occurred,
|
|
151
|
+
* and the client transaction SHOULD transition directly to the "Terminated" state.
|
|
152
|
+
* The TU will handle the fail over mechanisms described in [4].
|
|
153
|
+
* https://tools.ietf.org/html/rfc3261#section-17.1.4
|
|
154
|
+
* @param error - Transport error
|
|
155
|
+
*/
|
|
156
|
+
protected onTransportError(error: Error): void {
|
|
157
|
+
if (this.user.onTransportError) {
|
|
158
|
+
this.user.onTransportError(error);
|
|
159
|
+
}
|
|
160
|
+
this.stateTransition(TransactionState.Terminated, true);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** For logging. */
|
|
164
|
+
protected typeToString(): string {
|
|
165
|
+
return "non-INVITE client transaction";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Execute a state transition.
|
|
170
|
+
* @param newState - New state.
|
|
171
|
+
*/
|
|
172
|
+
private stateTransition(newState: TransactionState, dueToTransportError = false): void {
|
|
173
|
+
// Assert valid state transitions.
|
|
174
|
+
const invalidStateTransition = (): void => {
|
|
175
|
+
throw new Error(`Invalid state transition from ${this.state} to ${newState}`);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
switch (newState) {
|
|
179
|
+
case TransactionState.Trying:
|
|
180
|
+
invalidStateTransition();
|
|
181
|
+
break;
|
|
182
|
+
case TransactionState.Proceeding:
|
|
183
|
+
if (this.state !== TransactionState.Trying) {
|
|
184
|
+
invalidStateTransition();
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
case TransactionState.Completed:
|
|
188
|
+
if (this.state !== TransactionState.Trying && this.state !== TransactionState.Proceeding) {
|
|
189
|
+
invalidStateTransition();
|
|
190
|
+
}
|
|
191
|
+
break;
|
|
192
|
+
case TransactionState.Terminated:
|
|
193
|
+
if (
|
|
194
|
+
this.state !== TransactionState.Trying &&
|
|
195
|
+
this.state !== TransactionState.Proceeding &&
|
|
196
|
+
this.state !== TransactionState.Completed
|
|
197
|
+
) {
|
|
198
|
+
if (!dueToTransportError) {
|
|
199
|
+
invalidStateTransition();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
default:
|
|
204
|
+
invalidStateTransition();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Once the client transaction enters the "Completed" state, it MUST set
|
|
208
|
+
// Timer K to fire in T4 seconds for unreliable transports, and zero
|
|
209
|
+
// seconds for reliable transports The "Completed" state exists to
|
|
210
|
+
// buffer any additional response retransmissions that may be received
|
|
211
|
+
// (which is why the client transaction remains there only for unreliable transports).
|
|
212
|
+
// https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
213
|
+
if (newState === TransactionState.Completed) {
|
|
214
|
+
if (this.F) {
|
|
215
|
+
clearTimeout(this.F);
|
|
216
|
+
this.F = undefined;
|
|
217
|
+
}
|
|
218
|
+
this.K = window.setTimeout(() => this.timerK(), Timers.TIMER_K);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Once the transaction is in the terminated state, it MUST be destroyed immediately.
|
|
222
|
+
// https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
223
|
+
if (newState === TransactionState.Terminated) {
|
|
224
|
+
this.dispose();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Update state.
|
|
228
|
+
this.setState(newState);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* If Timer F fires while the client transaction is still in the
|
|
233
|
+
* "Trying" state, the client transaction SHOULD inform the TU about the
|
|
234
|
+
* timeout, and then it SHOULD enter the "Terminated" state.
|
|
235
|
+
* If timer F fires while in the "Proceeding" state, the TU MUST be informed of
|
|
236
|
+
* a timeout, and the client transaction MUST transition to the terminated state.
|
|
237
|
+
* https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
238
|
+
*/
|
|
239
|
+
private timerF(): void {
|
|
240
|
+
this.logger.debug(`Timer F expired for non-INVITE client transaction ${this.id}.`);
|
|
241
|
+
if (this.state === TransactionState.Trying || this.state === TransactionState.Proceeding) {
|
|
242
|
+
this.onRequestTimeout();
|
|
243
|
+
this.stateTransition(TransactionState.Terminated);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* If Timer K fires while in this (COMPLETED) state, the client transaction
|
|
249
|
+
* MUST transition to the "Terminated" state.
|
|
250
|
+
* https://tools.ietf.org/html/rfc3261#section-17.1.2.2
|
|
251
|
+
*/
|
|
252
|
+
private timerK(): void {
|
|
253
|
+
if (this.state === TransactionState.Completed) {
|
|
254
|
+
this.stateTransition(TransactionState.Terminated);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|