ue-softphone-sdk 2.2.3 → 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 +49 -26
- 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,27 @@
|
|
|
1
|
+
import { IncomingMessageRequest, IncomingRequestMessage, ResponseOptions } from "../core";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A received message (incoming MESSAGE).
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export class Message {
|
|
8
|
+
/** @internal */
|
|
9
|
+
public constructor(private incomingMessageRequest: IncomingMessageRequest) {}
|
|
10
|
+
|
|
11
|
+
/** Incoming MESSAGE request message. */
|
|
12
|
+
public get request(): IncomingRequestMessage {
|
|
13
|
+
return this.incomingMessageRequest.message;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Accept the request. */
|
|
17
|
+
public accept(options?: ResponseOptions): Promise<void> {
|
|
18
|
+
this.incomingMessageRequest.accept(options);
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Reject the request. */
|
|
23
|
+
public reject(options?: ResponseOptions): Promise<void> {
|
|
24
|
+
this.incomingMessageRequest.reject(options);
|
|
25
|
+
return Promise.resolve();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OutgoingRequestDelegate, RequestOptions } from "../core";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link Messager.message}.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface MessagerMessageOptions {
|
|
8
|
+
/** See `core` API. */
|
|
9
|
+
requestDelegate?: OutgoingRequestDelegate;
|
|
10
|
+
/** See `core` API. */
|
|
11
|
+
requestOptions?: RequestOptions;
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { URI } from "../core";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link Messager} constructor.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface MessagerOptions {
|
|
8
|
+
/** Array of extra headers added to the MESSAGE. */
|
|
9
|
+
extraHeaders?: Array<string>;
|
|
10
|
+
/** @deprecated TODO: provide alternative. */
|
|
11
|
+
params?: {
|
|
12
|
+
fromDisplayName?: string;
|
|
13
|
+
fromTag?: string;
|
|
14
|
+
fromUri?: string | URI;
|
|
15
|
+
toDisplayName?: string;
|
|
16
|
+
toUri?: string | URI;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Body, C, Grammar, Logger, OutgoingRequestMessage, URI } from "../core";
|
|
2
|
+
import { MessagerMessageOptions } from "./messager-message-options";
|
|
3
|
+
import { MessagerOptions } from "./messager-options";
|
|
4
|
+
import { UserAgent } from "./user-agent";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A messager sends a {@link Message} (outgoing MESSAGE).
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export class Messager {
|
|
11
|
+
private logger: Logger;
|
|
12
|
+
private request: OutgoingRequestMessage;
|
|
13
|
+
private userAgent: UserAgent;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Constructs a new instance of the `Messager` class.
|
|
17
|
+
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
18
|
+
* @param targetURI - Request URI identifying the target of the message.
|
|
19
|
+
* @param content - Content for the body of the message.
|
|
20
|
+
* @param contentType - Content type of the body of the message.
|
|
21
|
+
* @param options - Options bucket. See {@link MessagerOptions} for details.
|
|
22
|
+
*/
|
|
23
|
+
public constructor(
|
|
24
|
+
userAgent: UserAgent,
|
|
25
|
+
targetURI: URI,
|
|
26
|
+
content: string,
|
|
27
|
+
contentType = "text/plain",
|
|
28
|
+
options: MessagerOptions = {}
|
|
29
|
+
) {
|
|
30
|
+
// Logger
|
|
31
|
+
this.logger = userAgent.getLogger("sip.Messager");
|
|
32
|
+
|
|
33
|
+
// Default options params
|
|
34
|
+
options.params = options.params || {};
|
|
35
|
+
|
|
36
|
+
// URIs
|
|
37
|
+
let fromURI: URI | undefined = userAgent.userAgentCore.configuration.aor;
|
|
38
|
+
if (options.params.fromUri) {
|
|
39
|
+
fromURI =
|
|
40
|
+
typeof options.params.fromUri === "string" ? Grammar.URIParse(options.params.fromUri) : options.params.fromUri;
|
|
41
|
+
}
|
|
42
|
+
if (!fromURI) {
|
|
43
|
+
throw new TypeError("Invalid from URI: " + options.params.fromUri);
|
|
44
|
+
}
|
|
45
|
+
let toURI: URI | undefined = targetURI;
|
|
46
|
+
if (options.params.toUri) {
|
|
47
|
+
toURI = typeof options.params.toUri === "string" ? Grammar.URIParse(options.params.toUri) : options.params.toUri;
|
|
48
|
+
}
|
|
49
|
+
if (!toURI) {
|
|
50
|
+
throw new TypeError("Invalid to URI: " + options.params.toUri);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Message params
|
|
54
|
+
const params = options.params ? { ...options.params } : {};
|
|
55
|
+
|
|
56
|
+
// Extra headers
|
|
57
|
+
const extraHeaders = (options.extraHeaders || []).slice();
|
|
58
|
+
|
|
59
|
+
// Body
|
|
60
|
+
const contentDisposition = "render";
|
|
61
|
+
const body: Body = {
|
|
62
|
+
contentDisposition,
|
|
63
|
+
contentType,
|
|
64
|
+
content
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Build the request
|
|
68
|
+
this.request = userAgent.userAgentCore.makeOutgoingRequestMessage(
|
|
69
|
+
C.MESSAGE,
|
|
70
|
+
targetURI,
|
|
71
|
+
fromURI,
|
|
72
|
+
toURI,
|
|
73
|
+
params,
|
|
74
|
+
extraHeaders,
|
|
75
|
+
body
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// User agent
|
|
79
|
+
this.userAgent = userAgent;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Send the message.
|
|
84
|
+
*/
|
|
85
|
+
public message(options: MessagerMessageOptions = {}): Promise<void> {
|
|
86
|
+
this.userAgent.userAgentCore.request(this.request, options.requestDelegate);
|
|
87
|
+
return Promise.resolve();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IncomingNotifyRequest, IncomingRequestMessage, ResponseOptions } from "../core";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A notification of an event (incoming NOTIFY).
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export class Notification {
|
|
8
|
+
/** @internal */
|
|
9
|
+
public constructor(private incomingNotifyRequest: IncomingNotifyRequest) {}
|
|
10
|
+
|
|
11
|
+
/** Incoming NOTIFY request message. */
|
|
12
|
+
public get request(): IncomingRequestMessage {
|
|
13
|
+
return this.incomingNotifyRequest.message;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Accept the request. */
|
|
17
|
+
public accept(options?: ResponseOptions): Promise<void> {
|
|
18
|
+
this.incomingNotifyRequest.accept(options);
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Reject the request. */
|
|
23
|
+
public reject(options?: ResponseOptions): Promise<void> {
|
|
24
|
+
this.incomingNotifyRequest.reject(options);
|
|
25
|
+
return Promise.resolve();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { URI } from "../core";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link Publisher} constructor.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface PublisherOptions {
|
|
8
|
+
/** @deprecated TODO: provide alternative. */
|
|
9
|
+
body?: string;
|
|
10
|
+
/** @deprecated TODO: provide alternative. */
|
|
11
|
+
contentType?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Expire value for the published event.
|
|
14
|
+
* @defaultValue 3600
|
|
15
|
+
*/
|
|
16
|
+
expires?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Array of extra headers added to the PUBLISH request message.
|
|
19
|
+
*/
|
|
20
|
+
extraHeaders?: Array<string>;
|
|
21
|
+
/** @deprecated TODO: provide alternative. */
|
|
22
|
+
params?: {
|
|
23
|
+
fromDisplayName?: string;
|
|
24
|
+
fromTag?: string;
|
|
25
|
+
fromUri?: URI;
|
|
26
|
+
toDisplayName?: string;
|
|
27
|
+
toUri?: URI;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* If set true, UA will gracefully unpublish for the event on UA close.
|
|
31
|
+
* @defaultValue true
|
|
32
|
+
*/
|
|
33
|
+
unpublishOnClose?: boolean;
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@link Publisher} state.
|
|
3
|
+
* @remarks
|
|
4
|
+
* The {@link Publisher} behaves in a deterministic manner according to the following
|
|
5
|
+
* Finite State Machine (FSM).
|
|
6
|
+
* ```txt
|
|
7
|
+
* __________________________________________
|
|
8
|
+
* | __________________________ |
|
|
9
|
+
* Publisher | | v v
|
|
10
|
+
* Constructed -> Initial -> Published -> Unpublished -> Terminated
|
|
11
|
+
* | ^____________| ^
|
|
12
|
+
* |______________________________|
|
|
13
|
+
* ```
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export enum PublisherState {
|
|
17
|
+
Initial = "Initial",
|
|
18
|
+
Published = "Published",
|
|
19
|
+
Unpublished = "Unpublished",
|
|
20
|
+
Terminated = "Terminated"
|
|
21
|
+
}
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
C,
|
|
4
|
+
fromBodyLegacy,
|
|
5
|
+
IncomingResponseMessage,
|
|
6
|
+
Logger,
|
|
7
|
+
OutgoingPublishRequest,
|
|
8
|
+
OutgoingRequestMessage,
|
|
9
|
+
URI
|
|
10
|
+
} from "../core";
|
|
11
|
+
import { Emitter, EmitterImpl } from "./emitter";
|
|
12
|
+
import { PublisherOptions } from "./publisher-options";
|
|
13
|
+
import { PublisherPublishOptions } from "./publisher-publish-options";
|
|
14
|
+
import { PublisherState } from "./publisher-state";
|
|
15
|
+
import { PublisherUnpublishOptions } from "./publisher-unpublish-options";
|
|
16
|
+
import { BodyAndContentType } from "./session-description-handler";
|
|
17
|
+
import { UserAgent } from "./user-agent";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A publisher publishes a publication (outgoing PUBLISH).
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export class Publisher {
|
|
24
|
+
private event: string;
|
|
25
|
+
private options: PublisherOptions;
|
|
26
|
+
private target: URI;
|
|
27
|
+
private pubRequestBody: string | undefined;
|
|
28
|
+
private pubRequestExpires: number;
|
|
29
|
+
private pubRequestEtag: string | undefined;
|
|
30
|
+
private publishRefreshTimer: number | undefined;
|
|
31
|
+
|
|
32
|
+
private disposed = false;
|
|
33
|
+
private id: string;
|
|
34
|
+
private logger: Logger;
|
|
35
|
+
private request: OutgoingRequestMessage;
|
|
36
|
+
private userAgent: UserAgent;
|
|
37
|
+
|
|
38
|
+
/** The publication state. */
|
|
39
|
+
private _state: PublisherState = PublisherState.Initial;
|
|
40
|
+
/** Emits when the registration state changes. */
|
|
41
|
+
private _stateEventEmitter: EmitterImpl<PublisherState>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Constructs a new instance of the `Publisher` class.
|
|
45
|
+
*
|
|
46
|
+
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
47
|
+
* @param targetURI - Request URI identifying the target of the message.
|
|
48
|
+
* @param eventType - The event type identifying the published document.
|
|
49
|
+
* @param options - Options bucket. See {@link PublisherOptions} for details.
|
|
50
|
+
*/
|
|
51
|
+
public constructor(userAgent: UserAgent, targetURI: URI, eventType: string, options: PublisherOptions = {}) {
|
|
52
|
+
// state emitter
|
|
53
|
+
this._stateEventEmitter = new EmitterImpl<PublisherState>();
|
|
54
|
+
|
|
55
|
+
this.userAgent = userAgent;
|
|
56
|
+
|
|
57
|
+
options.extraHeaders = (options.extraHeaders || []).slice();
|
|
58
|
+
options.contentType = options.contentType || "text/plain";
|
|
59
|
+
|
|
60
|
+
if (typeof options.expires !== "number" || options.expires % 1 !== 0) {
|
|
61
|
+
options.expires = 3600;
|
|
62
|
+
} else {
|
|
63
|
+
options.expires = Number(options.expires);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (typeof options.unpublishOnClose !== "boolean") {
|
|
67
|
+
options.unpublishOnClose = true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.target = targetURI;
|
|
71
|
+
this.event = eventType;
|
|
72
|
+
this.options = options;
|
|
73
|
+
this.pubRequestExpires = options.expires;
|
|
74
|
+
|
|
75
|
+
this.logger = userAgent.getLogger("sip.Publisher");
|
|
76
|
+
|
|
77
|
+
const params = options.params || {};
|
|
78
|
+
const fromURI = params.fromUri ? params.fromUri : userAgent.userAgentCore.configuration.aor;
|
|
79
|
+
const toURI = params.toUri ? params.toUri : targetURI;
|
|
80
|
+
let body: Body | undefined;
|
|
81
|
+
if (options.body && options.contentType) {
|
|
82
|
+
const contentDisposition = "render";
|
|
83
|
+
const contentType = options.contentType;
|
|
84
|
+
const content = options.body;
|
|
85
|
+
body = {
|
|
86
|
+
contentDisposition,
|
|
87
|
+
contentType,
|
|
88
|
+
content
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const extraHeaders = (options.extraHeaders || []).slice();
|
|
92
|
+
|
|
93
|
+
// Build the request
|
|
94
|
+
this.request = userAgent.userAgentCore.makeOutgoingRequestMessage(
|
|
95
|
+
C.PUBLISH,
|
|
96
|
+
targetURI,
|
|
97
|
+
fromURI,
|
|
98
|
+
toURI,
|
|
99
|
+
params,
|
|
100
|
+
extraHeaders,
|
|
101
|
+
body
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// Identifier
|
|
105
|
+
this.id = this.target.toString() + ":" + this.event;
|
|
106
|
+
|
|
107
|
+
// Add to the user agent's publisher collection.
|
|
108
|
+
this.userAgent._publishers[this.id] = this;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Destructor.
|
|
113
|
+
*/
|
|
114
|
+
public dispose(): Promise<void> {
|
|
115
|
+
if (this.disposed) {
|
|
116
|
+
return Promise.resolve();
|
|
117
|
+
}
|
|
118
|
+
this.disposed = true;
|
|
119
|
+
this.logger.log(`Publisher ${this.id} in state ${this.state} is being disposed`);
|
|
120
|
+
|
|
121
|
+
// Remove from the user agent's publisher collection
|
|
122
|
+
delete this.userAgent._publishers[this.id];
|
|
123
|
+
|
|
124
|
+
// Send unpublish, if requested
|
|
125
|
+
if (this.options.unpublishOnClose && this.state === PublisherState.Published) {
|
|
126
|
+
return this.unpublish();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (this.publishRefreshTimer) {
|
|
130
|
+
clearTimeout(this.publishRefreshTimer);
|
|
131
|
+
this.publishRefreshTimer = undefined;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
this.pubRequestBody = undefined;
|
|
135
|
+
this.pubRequestExpires = 0;
|
|
136
|
+
this.pubRequestEtag = undefined;
|
|
137
|
+
|
|
138
|
+
return Promise.resolve();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** The publication state. */
|
|
142
|
+
public get state(): PublisherState {
|
|
143
|
+
return this._state;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Emits when the publisher state changes. */
|
|
147
|
+
public get stateChange(): Emitter<PublisherState> {
|
|
148
|
+
return this._stateEventEmitter;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Publish.
|
|
153
|
+
* @param content - Body to publish
|
|
154
|
+
*/
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
156
|
+
public publish(content: string, options: PublisherPublishOptions = {}): Promise<void> {
|
|
157
|
+
// Clean up before the run
|
|
158
|
+
if (this.publishRefreshTimer) {
|
|
159
|
+
clearTimeout(this.publishRefreshTimer);
|
|
160
|
+
this.publishRefreshTimer = undefined;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// is Initial or Modify request
|
|
164
|
+
this.options.body = content;
|
|
165
|
+
this.pubRequestBody = this.options.body;
|
|
166
|
+
|
|
167
|
+
if (this.pubRequestExpires === 0) {
|
|
168
|
+
// This is Initial request after unpublish
|
|
169
|
+
if (this.options.expires === undefined) {
|
|
170
|
+
throw new Error("Expires undefined.");
|
|
171
|
+
}
|
|
172
|
+
this.pubRequestExpires = this.options.expires;
|
|
173
|
+
this.pubRequestEtag = undefined;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this.sendPublishRequest();
|
|
177
|
+
|
|
178
|
+
return Promise.resolve();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Unpublish.
|
|
183
|
+
*/
|
|
184
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
185
|
+
public unpublish(options: PublisherUnpublishOptions = {}): Promise<void> {
|
|
186
|
+
// Clean up before the run
|
|
187
|
+
if (this.publishRefreshTimer) {
|
|
188
|
+
clearTimeout(this.publishRefreshTimer);
|
|
189
|
+
this.publishRefreshTimer = undefined;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.pubRequestBody = undefined;
|
|
193
|
+
this.pubRequestExpires = 0;
|
|
194
|
+
|
|
195
|
+
if (this.pubRequestEtag !== undefined) {
|
|
196
|
+
this.sendPublishRequest();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return Promise.resolve();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** @internal */
|
|
203
|
+
protected receiveResponse(response: IncomingResponseMessage): void {
|
|
204
|
+
const statusCode: number = response.statusCode || 0;
|
|
205
|
+
|
|
206
|
+
switch (true) {
|
|
207
|
+
case /^1[0-9]{2}$/.test(statusCode.toString()):
|
|
208
|
+
break;
|
|
209
|
+
case /^2[0-9]{2}$/.test(statusCode.toString()):
|
|
210
|
+
// Set SIP-Etag
|
|
211
|
+
if (response.hasHeader("SIP-ETag")) {
|
|
212
|
+
this.pubRequestEtag = response.getHeader("SIP-ETag");
|
|
213
|
+
} else {
|
|
214
|
+
this.logger.warn("SIP-ETag header missing in a 200-class response to PUBLISH");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Update Expire
|
|
218
|
+
if (response.hasHeader("Expires")) {
|
|
219
|
+
const expires = Number(response.getHeader("Expires"));
|
|
220
|
+
if (typeof expires === "number" && expires >= 0 && expires <= this.pubRequestExpires) {
|
|
221
|
+
this.pubRequestExpires = expires;
|
|
222
|
+
} else {
|
|
223
|
+
this.logger.warn("Bad Expires header in a 200-class response to PUBLISH");
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
this.logger.warn("Expires header missing in a 200-class response to PUBLISH");
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (this.pubRequestExpires !== 0) {
|
|
230
|
+
// Schedule refresh
|
|
231
|
+
this.publishRefreshTimer = window.setTimeout(() => this.refreshRequest(), this.pubRequestExpires * 900);
|
|
232
|
+
this.stateTransition(PublisherState.Published);
|
|
233
|
+
} else {
|
|
234
|
+
this.stateTransition(PublisherState.Unpublished);
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
case /^412$/.test(statusCode.toString()):
|
|
238
|
+
// 412 code means no matching ETag - possibly the PUBLISH expired
|
|
239
|
+
// Resubmit as new request, if the current request is not a "remove"
|
|
240
|
+
|
|
241
|
+
if (this.pubRequestEtag !== undefined && this.pubRequestExpires !== 0) {
|
|
242
|
+
this.logger.warn("412 response to PUBLISH, recovering");
|
|
243
|
+
this.pubRequestEtag = undefined;
|
|
244
|
+
if (this.options.body === undefined) {
|
|
245
|
+
throw new Error("Body undefined.");
|
|
246
|
+
}
|
|
247
|
+
this.publish(this.options.body);
|
|
248
|
+
} else {
|
|
249
|
+
this.logger.warn("412 response to PUBLISH, recovery failed");
|
|
250
|
+
this.pubRequestExpires = 0;
|
|
251
|
+
this.stateTransition(PublisherState.Unpublished);
|
|
252
|
+
this.stateTransition(PublisherState.Terminated);
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
255
|
+
case /^423$/.test(statusCode.toString()):
|
|
256
|
+
// 423 code means we need to adjust the Expires interval up
|
|
257
|
+
if (this.pubRequestExpires !== 0 && response.hasHeader("Min-Expires")) {
|
|
258
|
+
const minExpires = Number(response.getHeader("Min-Expires"));
|
|
259
|
+
if (typeof minExpires === "number" || minExpires > this.pubRequestExpires) {
|
|
260
|
+
this.logger.warn("423 code in response to PUBLISH, adjusting the Expires value and trying to recover");
|
|
261
|
+
this.pubRequestExpires = minExpires;
|
|
262
|
+
if (this.options.body === undefined) {
|
|
263
|
+
throw new Error("Body undefined.");
|
|
264
|
+
}
|
|
265
|
+
this.publish(this.options.body);
|
|
266
|
+
} else {
|
|
267
|
+
this.logger.warn("Bad 423 response Min-Expires header received for PUBLISH");
|
|
268
|
+
this.pubRequestExpires = 0;
|
|
269
|
+
this.stateTransition(PublisherState.Unpublished);
|
|
270
|
+
this.stateTransition(PublisherState.Terminated);
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
this.logger.warn("423 response to PUBLISH, recovery failed");
|
|
274
|
+
this.pubRequestExpires = 0;
|
|
275
|
+
this.stateTransition(PublisherState.Unpublished);
|
|
276
|
+
this.stateTransition(PublisherState.Terminated);
|
|
277
|
+
}
|
|
278
|
+
break;
|
|
279
|
+
default:
|
|
280
|
+
this.pubRequestExpires = 0;
|
|
281
|
+
this.stateTransition(PublisherState.Unpublished);
|
|
282
|
+
this.stateTransition(PublisherState.Terminated);
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Do the cleanup
|
|
287
|
+
if (this.pubRequestExpires === 0) {
|
|
288
|
+
if (this.publishRefreshTimer) {
|
|
289
|
+
clearTimeout(this.publishRefreshTimer);
|
|
290
|
+
this.publishRefreshTimer = undefined;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
this.pubRequestBody = undefined;
|
|
294
|
+
this.pubRequestEtag = undefined;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** @internal */
|
|
299
|
+
protected send(): OutgoingPublishRequest {
|
|
300
|
+
return this.userAgent.userAgentCore.publish(this.request, {
|
|
301
|
+
onAccept: (response): void => this.receiveResponse(response.message),
|
|
302
|
+
onProgress: (response): void => this.receiveResponse(response.message),
|
|
303
|
+
onRedirect: (response): void => this.receiveResponse(response.message),
|
|
304
|
+
onReject: (response): void => this.receiveResponse(response.message),
|
|
305
|
+
onTrying: (response): void => this.receiveResponse(response.message)
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
private refreshRequest(): void {
|
|
310
|
+
// Clean up before the run
|
|
311
|
+
if (this.publishRefreshTimer) {
|
|
312
|
+
clearTimeout(this.publishRefreshTimer);
|
|
313
|
+
this.publishRefreshTimer = undefined;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// This is Refresh request
|
|
317
|
+
this.pubRequestBody = undefined;
|
|
318
|
+
|
|
319
|
+
if (this.pubRequestEtag === undefined) {
|
|
320
|
+
throw new Error("Etag undefined");
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (this.pubRequestExpires === 0) {
|
|
324
|
+
throw new Error("Expires zero");
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
this.sendPublishRequest();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private sendPublishRequest(): OutgoingPublishRequest {
|
|
331
|
+
const reqOptions = { ...this.options };
|
|
332
|
+
|
|
333
|
+
reqOptions.extraHeaders = (this.options.extraHeaders || []).slice();
|
|
334
|
+
|
|
335
|
+
reqOptions.extraHeaders.push("Event: " + this.event);
|
|
336
|
+
reqOptions.extraHeaders.push("Expires: " + this.pubRequestExpires);
|
|
337
|
+
|
|
338
|
+
if (this.pubRequestEtag !== undefined) {
|
|
339
|
+
reqOptions.extraHeaders.push("SIP-If-Match: " + this.pubRequestEtag);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const ruri = this.target;
|
|
343
|
+
const params = this.options.params || {};
|
|
344
|
+
let bodyAndContentType: BodyAndContentType | undefined;
|
|
345
|
+
if (this.pubRequestBody !== undefined) {
|
|
346
|
+
if (this.options.contentType === undefined) {
|
|
347
|
+
throw new Error("Content type undefined.");
|
|
348
|
+
}
|
|
349
|
+
bodyAndContentType = {
|
|
350
|
+
body: this.pubRequestBody,
|
|
351
|
+
contentType: this.options.contentType
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
let body: Body | undefined;
|
|
355
|
+
if (bodyAndContentType) {
|
|
356
|
+
body = fromBodyLegacy(bodyAndContentType);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
this.request = this.userAgent.userAgentCore.makeOutgoingRequestMessage(
|
|
360
|
+
C.PUBLISH,
|
|
361
|
+
ruri,
|
|
362
|
+
params.fromUri ? params.fromUri : this.userAgent.userAgentCore.configuration.aor,
|
|
363
|
+
params.toUri ? params.toUri : this.target,
|
|
364
|
+
params,
|
|
365
|
+
reqOptions.extraHeaders,
|
|
366
|
+
body
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
return this.send();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Transition publication state.
|
|
374
|
+
*/
|
|
375
|
+
private stateTransition(newState: PublisherState): void {
|
|
376
|
+
const invalidTransition = (): void => {
|
|
377
|
+
throw new Error(`Invalid state transition from ${this._state} to ${newState}`);
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
// Validate transition
|
|
381
|
+
switch (this._state) {
|
|
382
|
+
case PublisherState.Initial:
|
|
383
|
+
if (
|
|
384
|
+
newState !== PublisherState.Published &&
|
|
385
|
+
newState !== PublisherState.Unpublished &&
|
|
386
|
+
newState !== PublisherState.Terminated
|
|
387
|
+
) {
|
|
388
|
+
invalidTransition();
|
|
389
|
+
}
|
|
390
|
+
break;
|
|
391
|
+
case PublisherState.Published:
|
|
392
|
+
if (newState !== PublisherState.Unpublished && newState !== PublisherState.Terminated) {
|
|
393
|
+
invalidTransition();
|
|
394
|
+
}
|
|
395
|
+
break;
|
|
396
|
+
case PublisherState.Unpublished:
|
|
397
|
+
if (newState !== PublisherState.Published && newState !== PublisherState.Terminated) {
|
|
398
|
+
invalidTransition();
|
|
399
|
+
}
|
|
400
|
+
break;
|
|
401
|
+
case PublisherState.Terminated:
|
|
402
|
+
invalidTransition();
|
|
403
|
+
break;
|
|
404
|
+
default:
|
|
405
|
+
throw new Error("Unrecognized state.");
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Transition
|
|
409
|
+
this._state = newState;
|
|
410
|
+
this.logger.log(`Publication transitioned to state ${this._state}`);
|
|
411
|
+
this._stateEventEmitter.emit(this._state);
|
|
412
|
+
|
|
413
|
+
// Dispose
|
|
414
|
+
if (newState === PublisherState.Terminated) {
|
|
415
|
+
this.dispose();
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|