ue-softphone-sdk 2.1.9 → 2.2.1
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/{index.d.ts → types/index.d.ts} +3 -7
- package/dist/ue-softphone-sdk.js +1 -2
- package/package.json +6 -6
- package/{new-rollup.config.mjs → rollup-new.config.mjs} +1 -1
- package/rollup.config.js +14 -15
- package/src/index.ts +23 -49
- package/tsconfig.json +10 -26
- package/dist/api/bye.d.ts +0 -16
- package/dist/api/dtmf.d.ts +0 -15
- package/dist/api/emitter.d.ts +0 -88
- package/dist/api/exceptions/content-type-unsupported.d.ts +0 -8
- package/dist/api/exceptions/index.d.ts +0 -5
- package/dist/api/exceptions/request-pending.d.ts +0 -9
- package/dist/api/exceptions/session-description-handler.d.ts +0 -8
- package/dist/api/exceptions/session-terminated.d.ts +0 -8
- package/dist/api/exceptions/state-transition.d.ts +0 -8
- package/dist/api/index.d.ts +0 -58
- package/dist/api/info.d.ts +0 -16
- package/dist/api/invitation-accept-options.d.ts +0 -19
- package/dist/api/invitation-progress-options.d.ts +0 -38
- package/dist/api/invitation-reject-options.d.ts +0 -25
- package/dist/api/invitation.d.ts +0 -179
- package/dist/api/inviter-cancel-options.d.ts +0 -9
- package/dist/api/inviter-invite-options.d.ts +0 -28
- package/dist/api/inviter-options.d.ts +0 -43
- package/dist/api/inviter.d.ts +0 -236
- package/dist/api/message.d.ts +0 -16
- package/dist/api/messager-message-options.d.ts +0 -11
- package/dist/api/messager-options.d.ts +0 -17
- package/dist/api/messager.d.ts +0 -26
- package/dist/api/notification.d.ts +0 -16
- package/dist/api/notifier.d.ts +0 -8
- package/dist/api/publisher-options.d.ts +0 -33
- package/dist/api/publisher-publish-options.d.ts +0 -6
- package/dist/api/publisher-state.d.ts +0 -21
- package/dist/api/publisher-unpublish-options.d.ts +0 -6
- package/dist/api/publisher.d.ts +0 -65
- package/dist/api/referral.d.ts +0 -38
- package/dist/api/registerer-options.d.ts +0 -46
- package/dist/api/registerer-register-options.d.ts +0 -11
- package/dist/api/registerer-state.d.ts +0 -21
- package/dist/api/registerer-unregister-options.d.ts +0 -16
- package/dist/api/registerer.d.ts +0 -144
- package/dist/api/session-bye-options.d.ts +0 -11
- package/dist/api/session-delegate.d.ts +0 -73
- package/dist/api/session-description-handler-factory.d.ts +0 -15
- package/dist/api/session-description-handler.d.ts +0 -74
- package/dist/api/session-info-options.d.ts +0 -11
- package/dist/api/session-invite-options.d.ts +0 -28
- package/dist/api/session-message-options.d.ts +0 -11
- package/dist/api/session-options.d.ts +0 -8
- package/dist/api/session-refer-options.d.ts +0 -14
- package/dist/api/session-state.d.ts +0 -45
- package/dist/api/session.d.ts +0 -359
- package/dist/api/subscriber-options.d.ts +0 -11
- package/dist/api/subscriber-subscribe-options.d.ts +0 -6
- package/dist/api/subscriber.d.ts +0 -94
- package/dist/api/subscription-delegate.d.ts +0 -12
- package/dist/api/subscription-options.d.ts +0 -8
- package/dist/api/subscription-state.d.ts +0 -19
- package/dist/api/subscription-subscribe-options.d.ts +0 -6
- package/dist/api/subscription-unsubscribe-options.d.ts +0 -6
- package/dist/api/subscription.d.ts +0 -84
- package/dist/api/transport-state.d.ts +0 -37
- package/dist/api/transport.d.ts +0 -159
- package/dist/api/user-agent-delegate.d.ts +0 -84
- package/dist/api/user-agent-options.d.ts +0 -253
- package/dist/api/user-agent-state.d.ts +0 -14
- package/dist/api/user-agent.d.ts +0 -200
- package/dist/core/dialogs/dialog-state.d.ts +0 -34
- package/dist/core/dialogs/dialog.d.ts +0 -161
- package/dist/core/dialogs/index.d.ts +0 -4
- package/dist/core/dialogs/session-dialog.d.ts +0 -196
- package/dist/core/dialogs/subscription-dialog.d.ts +0 -120
- package/dist/core/exceptions/exception.d.ts +0 -8
- package/dist/core/exceptions/index.d.ts +0 -3
- package/dist/core/exceptions/transaction-state-error.d.ts +0 -8
- package/dist/core/exceptions/transport-error.d.ts +0 -8
- package/dist/core/index.d.ts +0 -15
- package/dist/core/log/index.d.ts +0 -3
- package/dist/core/log/levels.d.ts +0 -10
- package/dist/core/log/logger-factory.d.ts +0 -21
- package/dist/core/log/logger.d.ts +0 -19
- package/dist/core/messages/body.d.ts +0 -64
- package/dist/core/messages/digest-authentication.d.ts +0 -51
- package/dist/core/messages/incoming-message.d.ts +0 -79
- package/dist/core/messages/incoming-request-message.d.ts +0 -10
- package/dist/core/messages/incoming-request.d.ts +0 -67
- package/dist/core/messages/incoming-response-message.d.ts +0 -10
- package/dist/core/messages/incoming-response.d.ts +0 -12
- package/dist/core/messages/index.d.ts +0 -13
- package/dist/core/messages/md5.d.ts +0 -32
- package/dist/core/messages/methods/ack.d.ts +0 -18
- package/dist/core/messages/methods/bye.d.ts +0 -21
- package/dist/core/messages/methods/cancel.d.ts +0 -21
- package/dist/core/messages/methods/constants.d.ts +0 -20
- package/dist/core/messages/methods/index.d.ts +0 -13
- package/dist/core/messages/methods/info.d.ts +0 -21
- package/dist/core/messages/methods/invite.d.ts +0 -86
- package/dist/core/messages/methods/message.d.ts +0 -21
- package/dist/core/messages/methods/notify.d.ts +0 -21
- package/dist/core/messages/methods/prack.d.ts +0 -21
- package/dist/core/messages/methods/publish.d.ts +0 -21
- package/dist/core/messages/methods/refer.d.ts +0 -21
- package/dist/core/messages/methods/register.d.ts +0 -21
- package/dist/core/messages/methods/subscribe.d.ts +0 -54
- package/dist/core/messages/outgoing-request-message.d.ts +0 -94
- package/dist/core/messages/outgoing-request.d.ts +0 -67
- package/dist/core/messages/outgoing-response.d.ts +0 -42
- package/dist/core/messages/parser.d.ts +0 -14
- package/dist/core/messages/utils.d.ts +0 -24
- package/dist/core/session/index.d.ts +0 -2
- package/dist/core/session/session-delegate.d.ts +0 -70
- package/dist/core/session/session.d.ts +0 -134
- package/dist/core/subscription/index.d.ts +0 -2
- package/dist/core/subscription/subscription-delegate.d.ts +0 -27
- package/dist/core/subscription/subscription.d.ts +0 -55
- package/dist/core/timers.d.ts +0 -20
- package/dist/core/transactions/client-transaction.d.ts +0 -45
- package/dist/core/transactions/index.d.ts +0 -10
- package/dist/core/transactions/invite-client-transaction.d.ts +0 -116
- package/dist/core/transactions/invite-server-transaction.d.ts +0 -127
- package/dist/core/transactions/non-invite-client-transaction.d.ts +0 -69
- package/dist/core/transactions/non-invite-server-transaction.d.ts +0 -57
- package/dist/core/transactions/server-transaction.d.ts +0 -35
- package/dist/core/transactions/transaction-state.d.ts +0 -13
- package/dist/core/transactions/transaction-user.d.ts +0 -72
- package/dist/core/transactions/transaction.d.ts +0 -79
- package/dist/core/transport.d.ts +0 -31
- package/dist/core/user-agent-core/allowed-methods.d.ts +0 -4
- package/dist/core/user-agent-core/index.d.ts +0 -3
- package/dist/core/user-agent-core/user-agent-core-configuration.d.ts +0 -99
- package/dist/core/user-agent-core/user-agent-core-delegate.d.ts +0 -37
- package/dist/core/user-agent-core/user-agent-core.d.ts +0 -179
- package/dist/core/user-agents/bye-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/bye-user-agent-server.d.ts +0 -10
- package/dist/core/user-agents/cancel-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/index.d.ts +0 -26
- package/dist/core/user-agents/info-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/info-user-agent-server.d.ts +0 -10
- package/dist/core/user-agents/invite-user-agent-client.d.ts +0 -35
- package/dist/core/user-agents/invite-user-agent-server.d.ts +0 -77
- package/dist/core/user-agents/message-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/message-user-agent-server.d.ts +0 -10
- package/dist/core/user-agents/notify-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/notify-user-agent-server.d.ts +0 -16
- package/dist/core/user-agents/prack-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/prack-user-agent-server.d.ts +0 -16
- package/dist/core/user-agents/publish-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/re-invite-user-agent-client.d.ts +0 -18
- package/dist/core/user-agents/re-invite-user-agent-server.d.ts +0 -41
- package/dist/core/user-agents/re-subscribe-user-agent-client.d.ts +0 -17
- package/dist/core/user-agents/re-subscribe-user-agent-server.d.ts +0 -10
- package/dist/core/user-agents/refer-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/refer-user-agent-server.d.ts +0 -16
- package/dist/core/user-agents/register-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/register-user-agent-server.d.ts +0 -11
- package/dist/core/user-agents/subscribe-user-agent-client.d.ts +0 -65
- package/dist/core/user-agents/subscribe-user-agent-server.d.ts +0 -11
- package/dist/core/user-agents/user-agent-client.d.ts +0 -103
- package/dist/core/user-agents/user-agent-server.d.ts +0 -79
- package/dist/grammar/grammar.d.ts +0 -26
- package/dist/grammar/index.d.ts +0 -4
- package/dist/grammar/name-addr-header.d.ts +0 -24
- package/dist/grammar/parameters.d.ts +0 -16
- package/dist/grammar/pegjs/dist/grammar.d.ts +0 -50
- package/dist/grammar/uri.d.ts +0 -62
- package/dist/main.d.ts +0 -9
- package/dist/new-index.d.ts +0 -199
- package/dist/platform/web/index.d.ts +0 -4
- package/dist/platform/web/modifiers/index.d.ts +0 -5
- package/dist/platform/web/modifiers/modifiers.d.ts +0 -41
- package/dist/platform/web/session-description-handler/index.d.ts +0 -14
- package/dist/platform/web/session-description-handler/media-stream-factory-default.d.ts +0 -6
- package/dist/platform/web/session-description-handler/media-stream-factory.d.ts +0 -6
- package/dist/platform/web/session-description-handler/peer-connection-configuration-default.d.ts +0 -5
- package/dist/platform/web/session-description-handler/peer-connection-delegate.d.ts +0 -63
- package/dist/platform/web/session-description-handler/session-description-handler-configuration.d.ts +0 -16
- package/dist/platform/web/session-description-handler/session-description-handler-factory-default.d.ts +0 -11
- package/dist/platform/web/session-description-handler/session-description-handler-factory-options.d.ts +0 -9
- package/dist/platform/web/session-description-handler/session-description-handler-factory.d.ts +0 -16
- package/dist/platform/web/session-description-handler/session-description-handler-options.d.ts +0 -47
- package/dist/platform/web/session-description-handler/session-description-handler.d.ts +0 -212
- package/dist/platform/web/simple-user/index.d.ts +0 -7
- package/dist/platform/web/simple-user/simple-user-delegate.d.ts +0 -72
- package/dist/platform/web/simple-user/simple-user-options.d.ts +0 -90
- package/dist/platform/web/simple-user/simple-user.d.ts +0 -226
- package/dist/platform/web/transport/index.d.ts +0 -6
- package/dist/platform/web/transport/transport-options.d.ts +0 -30
- package/dist/platform/web/transport/transport.d.ts +0 -125
- package/dist/ue-softphone-sdk.js.map +0 -1
- package/dist/version.d.ts +0 -1
- package/dist/webPhoneSdk.d.ts +0 -24
- package/dist/webrtc.d.ts +0 -17
- package/src/api/api-extractor.json +0 -358
- package/src/api/bye.ts +0 -27
- package/src/api/dtmf.ts +0 -27
- package/src/api/emitter.ts +0 -110
- package/src/api/exceptions/content-type-unsupported.ts +0 -11
- package/src/api/exceptions/index.ts +0 -5
- package/src/api/exceptions/request-pending.ts +0 -12
- package/src/api/exceptions/session-description-handler.ts +0 -11
- package/src/api/exceptions/session-terminated.ts +0 -11
- package/src/api/exceptions/state-transition.ts +0 -11
- package/src/api/index.ts +0 -58
- package/src/api/info.ts +0 -27
- package/src/api/invitation-accept-options.ts +0 -20
- package/src/api/invitation-progress-options.ts +0 -36
- package/src/api/invitation-reject-options.ts +0 -22
- package/src/api/invitation.ts +0 -816
- package/src/api/inviter-cancel-options.ts +0 -9
- package/src/api/inviter-invite-options.ts +0 -29
- package/src/api/inviter-options.ts +0 -44
- package/src/api/inviter.ts +0 -1126
- package/src/api/message.ts +0 -27
- package/src/api/messager-message-options.ts +0 -12
- package/src/api/messager-options.ts +0 -18
- package/src/api/messager.ts +0 -89
- package/src/api/notification.ts +0 -27
- package/src/api/notifier.ts +0 -7
- package/src/api/publisher-options.ts +0 -34
- package/src/api/publisher-publish-options.ts +0 -6
- package/src/api/publisher-state.ts +0 -21
- package/src/api/publisher-unpublish-options.ts +0 -6
- package/src/api/publisher.ts +0 -418
- package/src/api/referral.ts +0 -89
- package/src/api/registerer-options.ts +0 -55
- package/src/api/registerer-register-options.ts +0 -12
- package/src/api/registerer-state.ts +0 -21
- package/src/api/registerer-unregister-options.ts +0 -17
- package/src/api/registerer.ts +0 -814
- package/src/api/session-bye-options.ts +0 -12
- package/src/api/session-delegate.ts +0 -80
- package/src/api/session-description-handler-factory.ts +0 -16
- package/src/api/session-description-handler.ts +0 -89
- package/src/api/session-info-options.ts +0 -12
- package/src/api/session-invite-options.ts +0 -29
- package/src/api/session-message-options.ts +0 -12
- package/src/api/session-options.ts +0 -8
- package/src/api/session-refer-options.ts +0 -15
- package/src/api/session-state.ts +0 -45
- package/src/api/session.ts +0 -1448
- package/src/api/subscriber-options.ts +0 -12
- package/src/api/subscriber-subscribe-options.ts +0 -6
- package/src/api/subscriber.ts +0 -536
- package/src/api/subscription-delegate.ts +0 -13
- package/src/api/subscription-options.ts +0 -8
- package/src/api/subscription-state.ts +0 -19
- package/src/api/subscription-subscribe-options.ts +0 -6
- package/src/api/subscription-unsubscribe-options.ts +0 -6
- package/src/api/subscription.ts +0 -161
- package/src/api/transport-state.ts +0 -37
- package/src/api/transport.ts +0 -169
- package/src/api/user-agent-delegate.ts +0 -95
- package/src/api/user-agent-options.ts +0 -322
- package/src/api/user-agent-state.ts +0 -14
- package/src/api/user-agent.ts +0 -1014
- package/src/core/api-extractor.json +0 -358
- package/src/core/dialogs/dialog-state.ts +0 -35
- package/src/core/dialogs/dialog.ts +0 -605
- package/src/core/dialogs/index.ts +0 -4
- package/src/core/dialogs/session-dialog.ts +0 -996
- package/src/core/dialogs/subscription-dialog.ts +0 -557
- package/src/core/exceptions/exception.ts +0 -11
- package/src/core/exceptions/index.ts +0 -3
- package/src/core/exceptions/transaction-state-error.ts +0 -11
- package/src/core/exceptions/transport-error.ts +0 -11
- package/src/core/index.ts +0 -19
- package/src/core/log/index.ts +0 -3
- package/src/core/log/levels.ts +0 -10
- package/src/core/log/logger-factory.ts +0 -119
- package/src/core/log/logger.ts +0 -42
- package/src/core/messages/body.ts +0 -171
- package/src/core/messages/digest-authentication.ts +0 -190
- package/src/core/messages/incoming-message.ts +0 -152
- package/src/core/messages/incoming-request-message.ts +0 -14
- package/src/core/messages/incoming-request.ts +0 -75
- package/src/core/messages/incoming-response-message.ts +0 -14
- package/src/core/messages/incoming-response.ts +0 -13
- package/src/core/messages/index.ts +0 -18
- package/src/core/messages/md5.ts +0 -437
- package/src/core/messages/methods/ack.ts +0 -22
- package/src/core/messages/methods/bye.ts +0 -22
- package/src/core/messages/methods/cancel.ts +0 -22
- package/src/core/messages/methods/constants.ts +0 -21
- package/src/core/messages/methods/index.ts +0 -13
- package/src/core/messages/methods/info.ts +0 -22
- package/src/core/messages/methods/invite.ts +0 -104
- package/src/core/messages/methods/message.ts +0 -22
- package/src/core/messages/methods/notify.ts +0 -22
- package/src/core/messages/methods/prack.ts +0 -22
- package/src/core/messages/methods/publish.ts +0 -22
- package/src/core/messages/methods/refer.ts +0 -22
- package/src/core/messages/methods/register.ts +0 -22
- package/src/core/messages/methods/subscribe.ts +0 -59
- package/src/core/messages/outgoing-request-message.ts +0 -299
- package/src/core/messages/outgoing-request.ts +0 -77
- package/src/core/messages/outgoing-response.ts +0 -174
- package/src/core/messages/parser.ts +0 -265
- package/src/core/messages/utils.ts +0 -144
- package/src/core/session/index.ts +0 -2
- package/src/core/session/session-delegate.ts +0 -88
- package/src/core/session/session.ts +0 -158
- package/src/core/subscription/index.ts +0 -2
- package/src/core/subscription/subscription-delegate.ts +0 -30
- package/src/core/subscription/subscription.ts +0 -61
- package/src/core/timers.ts +0 -24
- package/src/core/transactions/client-transaction.ts +0 -78
- package/src/core/transactions/index.ts +0 -10
- package/src/core/transactions/invite-client-transaction.ts +0 -504
- package/src/core/transactions/invite-server-transaction.ts +0 -432
- package/src/core/transactions/non-invite-client-transaction.ts +0 -257
- package/src/core/transactions/non-invite-server-transaction.ts +0 -241
- package/src/core/transactions/server-transaction.ts +0 -47
- package/src/core/transactions/transaction-state.ts +0 -13
- package/src/core/transactions/transaction-user.ts +0 -82
- package/src/core/transactions/transaction.ts +0 -149
- package/src/core/transport.ts +0 -32
- package/src/core/user-agent-core/allowed-methods.ts +0 -19
- package/src/core/user-agent-core/index.ts +0 -3
- package/src/core/user-agent-core/user-agent-core-configuration.ts +0 -111
- package/src/core/user-agent-core/user-agent-core-delegate.ts +0 -50
- package/src/core/user-agent-core/user-agent-core.ts +0 -905
- package/src/core/user-agents/bye-user-agent-client.ts +0 -16
- package/src/core/user-agents/bye-user-agent-server.ts +0 -14
- package/src/core/user-agents/cancel-user-agent-client.ts +0 -14
- package/src/core/user-agents/index.ts +0 -26
- package/src/core/user-agents/info-user-agent-client.ts +0 -15
- package/src/core/user-agents/info-user-agent-server.ts +0 -14
- package/src/core/user-agents/invite-user-agent-client.ts +0 -405
- package/src/core/user-agents/invite-user-agent-server.ts +0 -269
- package/src/core/user-agents/message-user-agent-client.ts +0 -14
- package/src/core/user-agents/message-user-agent-server.ts +0 -14
- package/src/core/user-agents/notify-user-agent-client.ts +0 -15
- package/src/core/user-agents/notify-user-agent-server.ts +0 -30
- package/src/core/user-agents/prack-user-agent-client.ts +0 -16
- package/src/core/user-agents/prack-user-agent-server.ts +0 -37
- package/src/core/user-agents/publish-user-agent-client.ts +0 -14
- package/src/core/user-agents/re-invite-user-agent-client.ts +0 -127
- package/src/core/user-agents/re-invite-user-agent-server.ts +0 -109
- package/src/core/user-agents/re-subscribe-user-agent-client.ts +0 -78
- package/src/core/user-agents/re-subscribe-user-agent-server.ts +0 -14
- package/src/core/user-agents/refer-user-agent-client.ts +0 -15
- package/src/core/user-agents/refer-user-agent-server.ts +0 -30
- package/src/core/user-agents/register-user-agent-client.ts +0 -14
- package/src/core/user-agents/register-user-agent-server.ts +0 -14
- package/src/core/user-agents/subscribe-user-agent-client.ts +0 -341
- package/src/core/user-agents/subscribe-user-agent-server.ts +0 -14
- package/src/core/user-agents/user-agent-client.ts +0 -378
- package/src/core/user-agents/user-agent-server.ts +0 -276
- package/src/grammar/grammar.ts +0 -55
- package/src/grammar/index.ts +0 -4
- package/src/grammar/name-addr-header.ts +0 -58
- package/src/grammar/parameters.ts +0 -45
- package/src/grammar/pegjs/README.md +0 -9
- package/src/grammar/pegjs/dist/grammar.ts +0 -1557
- package/src/grammar/pegjs/src/grammar.pegjs +0 -1009
- package/src/grammar/uri.ts +0 -370
- package/src/lib/socket.io.esm.min.js +0 -7
- package/src/main.ts +0 -26
- package/src/new-index.ts +0 -2478
- package/src/platform/react/README.md +0 -1
- package/src/platform/web/index.ts +0 -4
- package/src/platform/web/modifiers/index.ts +0 -5
- package/src/platform/web/modifiers/modifiers.ts +0 -180
- package/src/platform/web/session-description-handler/api-extractor.json +0 -358
- package/src/platform/web/session-description-handler/index.ts +0 -14
- package/src/platform/web/session-description-handler/media-stream-factory-default.ts +0 -22
- package/src/platform/web/session-description-handler/media-stream-factory.ts +0 -10
- package/src/platform/web/session-description-handler/peer-connection-configuration-default.ts +0 -17
- package/src/platform/web/session-description-handler/peer-connection-delegate.ts +0 -72
- package/src/platform/web/session-description-handler/session-description-handler-configuration.ts +0 -17
- package/src/platform/web/session-description-handler/session-description-handler-factory-default.ts +0 -45
- package/src/platform/web/session-description-handler/session-description-handler-factory-options.ts +0 -10
- package/src/platform/web/session-description-handler/session-description-handler-factory.ts +0 -17
- package/src/platform/web/session-description-handler/session-description-handler-options.ts +0 -56
- package/src/platform/web/session-description-handler/session-description-handler.ts +0 -938
- package/src/platform/web/simple-user/api-extractor.json +0 -358
- package/src/platform/web/simple-user/index.ts +0 -7
- package/src/platform/web/simple-user/simple-user-delegate.ts +0 -82
- package/src/platform/web/simple-user/simple-user-options.ts +0 -102
- package/src/platform/web/simple-user/simple-user.ts +0 -1099
- package/src/platform/web/transport/api-extractor.json +0 -358
- package/src/platform/web/transport/index.ts +0 -6
- package/src/platform/web/transport/transport-options.ts +0 -34
- package/src/platform/web/transport/transport.ts +0 -742
- package/src/version.ts +0 -8
- package/src/webPhoneSdk.ts +0 -67
- package/src/webrtc.ts +0 -318
- /package/dist/{config.d.ts → types/config.d.ts} +0 -0
|
@@ -1,996 +0,0 @@
|
|
|
1
|
-
import { Logger } from "../log";
|
|
2
|
-
import {
|
|
3
|
-
Body,
|
|
4
|
-
C,
|
|
5
|
-
getBody,
|
|
6
|
-
IncomingRequestMessage,
|
|
7
|
-
IncomingResponseMessage,
|
|
8
|
-
isBody,
|
|
9
|
-
NameAddrHeader,
|
|
10
|
-
OutgoingAckRequest,
|
|
11
|
-
OutgoingByeRequest,
|
|
12
|
-
OutgoingInfoRequest,
|
|
13
|
-
OutgoingInviteRequest,
|
|
14
|
-
OutgoingInviteRequestDelegate,
|
|
15
|
-
OutgoingMessageRequest,
|
|
16
|
-
OutgoingNotifyRequest,
|
|
17
|
-
OutgoingPrackRequest,
|
|
18
|
-
OutgoingReferRequest,
|
|
19
|
-
OutgoingRequestDelegate,
|
|
20
|
-
OutgoingRequestMessage,
|
|
21
|
-
RequestOptions
|
|
22
|
-
} from "../messages";
|
|
23
|
-
import { Session, SessionDelegate, SessionState, SignalingState } from "../session";
|
|
24
|
-
import { Timers } from "../timers";
|
|
25
|
-
import { InviteClientTransaction, InviteServerTransaction, TransactionState } from "../transactions";
|
|
26
|
-
import { UserAgentCore } from "../user-agent-core";
|
|
27
|
-
import { ByeUserAgentClient } from "../user-agents/bye-user-agent-client";
|
|
28
|
-
import { ByeUserAgentServer } from "../user-agents/bye-user-agent-server";
|
|
29
|
-
import { InfoUserAgentClient } from "../user-agents/info-user-agent-client";
|
|
30
|
-
import { InfoUserAgentServer } from "../user-agents/info-user-agent-server";
|
|
31
|
-
import { MessageUserAgentClient } from "../user-agents/message-user-agent-client";
|
|
32
|
-
import { MessageUserAgentServer } from "../user-agents/message-user-agent-server";
|
|
33
|
-
import { NotifyUserAgentClient } from "../user-agents/notify-user-agent-client";
|
|
34
|
-
import { NotifyUserAgentServer } from "../user-agents/notify-user-agent-server";
|
|
35
|
-
import { PrackUserAgentClient } from "../user-agents/prack-user-agent-client";
|
|
36
|
-
import { PrackUserAgentServer } from "../user-agents/prack-user-agent-server";
|
|
37
|
-
import { ReInviteUserAgentClient } from "../user-agents/re-invite-user-agent-client";
|
|
38
|
-
import { ReInviteUserAgentServer } from "../user-agents/re-invite-user-agent-server";
|
|
39
|
-
import { ReferUserAgentClient } from "../user-agents/refer-user-agent-client";
|
|
40
|
-
import { ReferUserAgentServer } from "../user-agents/refer-user-agent-server";
|
|
41
|
-
import { Dialog } from "./dialog";
|
|
42
|
-
import { DialogState } from "./dialog-state";
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Session Dialog.
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
export class SessionDialog extends Dialog implements Session {
|
|
49
|
-
public delegate: SessionDelegate | undefined;
|
|
50
|
-
|
|
51
|
-
public reinviteUserAgentClient: ReInviteUserAgentClient | undefined;
|
|
52
|
-
public reinviteUserAgentServer: ReInviteUserAgentServer | undefined;
|
|
53
|
-
|
|
54
|
-
/** The state of the offer/answer exchange. */
|
|
55
|
-
private _signalingState: SignalingState = SignalingState.Initial;
|
|
56
|
-
/** The current offer. Undefined unless signaling state HaveLocalOffer, HaveRemoteOffer, or Stable. */
|
|
57
|
-
private _offer: Body | undefined;
|
|
58
|
-
/** The current answer. Undefined unless signaling state Stable. */
|
|
59
|
-
private _answer: Body | undefined;
|
|
60
|
-
/** The rollback offer. Undefined unless signaling state HaveLocalOffer or HaveRemoteOffer. */
|
|
61
|
-
private _rollbackOffer: Body | undefined;
|
|
62
|
-
/** The rollback answer. Undefined unless signaling state HaveLocalOffer or HaveRemoteOffer. */
|
|
63
|
-
private _rollbackAnswer: Body | undefined;
|
|
64
|
-
|
|
65
|
-
/** True if waiting for an ACK to the initial transaction 2xx (UAS only). */
|
|
66
|
-
private ackWait = false;
|
|
67
|
-
/** True if processing an ACK to the initial transaction 2xx (UAS only). */
|
|
68
|
-
private ackProcessing = false;
|
|
69
|
-
/** Retransmission timer for 2xx response which confirmed the dialog. */
|
|
70
|
-
private invite2xxTimer: number | undefined;
|
|
71
|
-
/** The rseq of the last reliable response. */
|
|
72
|
-
private rseq: number | undefined;
|
|
73
|
-
|
|
74
|
-
private logger: Logger;
|
|
75
|
-
|
|
76
|
-
constructor(
|
|
77
|
-
private initialTransaction: InviteClientTransaction | InviteServerTransaction,
|
|
78
|
-
core: UserAgentCore,
|
|
79
|
-
state: DialogState,
|
|
80
|
-
delegate?: SessionDelegate
|
|
81
|
-
) {
|
|
82
|
-
super(core, state);
|
|
83
|
-
this.delegate = delegate;
|
|
84
|
-
if (initialTransaction instanceof InviteServerTransaction) {
|
|
85
|
-
// If we're created by an invite server transaction, we're
|
|
86
|
-
// going to be waiting for an ACK if are to be confirmed.
|
|
87
|
-
this.ackWait = true;
|
|
88
|
-
}
|
|
89
|
-
// If we're confirmed upon creation start the retransmitting whatever
|
|
90
|
-
// the 2xx final response was that confirmed us into existence.
|
|
91
|
-
if (!this.early) {
|
|
92
|
-
this.start2xxRetransmissionTimer();
|
|
93
|
-
}
|
|
94
|
-
this.signalingStateTransition(initialTransaction.request);
|
|
95
|
-
this.logger = core.loggerFactory.getLogger("sip.invite-dialog");
|
|
96
|
-
this.logger.log(`INVITE dialog ${this.id} constructed`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
public dispose(): void {
|
|
100
|
-
super.dispose();
|
|
101
|
-
this._signalingState = SignalingState.Closed;
|
|
102
|
-
this._offer = undefined;
|
|
103
|
-
this._answer = undefined;
|
|
104
|
-
if (this.invite2xxTimer) {
|
|
105
|
-
clearTimeout(this.invite2xxTimer);
|
|
106
|
-
this.invite2xxTimer = undefined;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// The UAS MUST still respond to any pending requests received for that
|
|
110
|
-
// dialog. It is RECOMMENDED that a 487 (Request Terminated) response
|
|
111
|
-
// be generated to those pending requests.
|
|
112
|
-
// https://tools.ietf.org/html/rfc3261#section-15.1.2
|
|
113
|
-
|
|
114
|
-
// TODO:
|
|
115
|
-
// this.userAgentServers.forEach((uas) => uas.reply(487));
|
|
116
|
-
|
|
117
|
-
this.logger.log(`INVITE dialog ${this.id} destroyed`);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// FIXME: Need real state machine
|
|
121
|
-
get sessionState(): SessionState {
|
|
122
|
-
if (this.early) {
|
|
123
|
-
return SessionState.Early;
|
|
124
|
-
} else if (this.ackWait) {
|
|
125
|
-
return SessionState.AckWait;
|
|
126
|
-
} else if (this._signalingState === SignalingState.Closed) {
|
|
127
|
-
return SessionState.Terminated;
|
|
128
|
-
} else {
|
|
129
|
-
return SessionState.Confirmed;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** The state of the offer/answer exchange. */
|
|
134
|
-
get signalingState(): SignalingState {
|
|
135
|
-
return this._signalingState;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/** The current offer. Undefined unless signaling state HaveLocalOffer, HaveRemoteOffer, of Stable. */
|
|
139
|
-
get offer(): Body | undefined {
|
|
140
|
-
return this._offer;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/** The current answer. Undefined unless signaling state Stable. */
|
|
144
|
-
get answer(): Body | undefined {
|
|
145
|
-
return this._answer;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/** Confirm the dialog. Only matters if dialog is currently early. */
|
|
149
|
-
public confirm(): void {
|
|
150
|
-
// When we're confirmed start the retransmitting whatever
|
|
151
|
-
// the 2xx final response that may have confirmed us.
|
|
152
|
-
if (this.early) {
|
|
153
|
-
this.start2xxRetransmissionTimer();
|
|
154
|
-
}
|
|
155
|
-
super.confirm();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/** Re-confirm the dialog. Only matters if handling re-INVITE request. */
|
|
159
|
-
public reConfirm(): void {
|
|
160
|
-
// When we're confirmed start the retransmitting whatever
|
|
161
|
-
// the 2xx final response that may have confirmed us.
|
|
162
|
-
if (this.reinviteUserAgentServer) {
|
|
163
|
-
this.startReInvite2xxRetransmissionTimer();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* The UAC core MUST generate an ACK request for each 2xx received from
|
|
169
|
-
* the transaction layer. The header fields of the ACK are constructed
|
|
170
|
-
* in the same way as for any request sent within a dialog (see Section
|
|
171
|
-
* 12) with the exception of the CSeq and the header fields related to
|
|
172
|
-
* authentication. The sequence number of the CSeq header field MUST be
|
|
173
|
-
* the same as the INVITE being acknowledged, but the CSeq method MUST
|
|
174
|
-
* be ACK. The ACK MUST contain the same credentials as the INVITE. If
|
|
175
|
-
* the 2xx contains an offer (based on the rules above), the ACK MUST
|
|
176
|
-
* carry an answer in its body. If the offer in the 2xx response is not
|
|
177
|
-
* acceptable, the UAC core MUST generate a valid answer in the ACK and
|
|
178
|
-
* then send a BYE immediately.
|
|
179
|
-
* https://tools.ietf.org/html/rfc3261#section-13.2.2.4
|
|
180
|
-
* @param options - ACK options bucket.
|
|
181
|
-
*/
|
|
182
|
-
public ack(options: RequestOptions = {}): OutgoingAckRequest {
|
|
183
|
-
this.logger.log(`INVITE dialog ${this.id} sending ACK request`);
|
|
184
|
-
let transaction: InviteClientTransaction;
|
|
185
|
-
if (this.reinviteUserAgentClient) {
|
|
186
|
-
// We're sending ACK for a re-INVITE
|
|
187
|
-
if (!(this.reinviteUserAgentClient.transaction instanceof InviteClientTransaction)) {
|
|
188
|
-
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
189
|
-
}
|
|
190
|
-
transaction = this.reinviteUserAgentClient.transaction;
|
|
191
|
-
this.reinviteUserAgentClient = undefined;
|
|
192
|
-
} else {
|
|
193
|
-
// We're sending ACK for the initial INVITE
|
|
194
|
-
if (!(this.initialTransaction instanceof InviteClientTransaction)) {
|
|
195
|
-
throw new Error("Initial transaction not instance of InviteClientTransaction.");
|
|
196
|
-
}
|
|
197
|
-
transaction = this.initialTransaction;
|
|
198
|
-
}
|
|
199
|
-
const message = this.createOutgoingRequestMessage(C.ACK, {
|
|
200
|
-
cseq: transaction.request.cseq, // ACK cseq is INVITE cseq
|
|
201
|
-
extraHeaders: options.extraHeaders,
|
|
202
|
-
body: options.body
|
|
203
|
-
});
|
|
204
|
-
transaction.ackResponse(message); // See InviteClientTransaction for details.
|
|
205
|
-
this.signalingStateTransition(message);
|
|
206
|
-
return { message };
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Terminating a Session
|
|
211
|
-
*
|
|
212
|
-
* This section describes the procedures for terminating a session
|
|
213
|
-
* established by SIP. The state of the session and the state of the
|
|
214
|
-
* dialog are very closely related. When a session is initiated with an
|
|
215
|
-
* INVITE, each 1xx or 2xx response from a distinct UAS creates a
|
|
216
|
-
* dialog, and if that response completes the offer/answer exchange, it
|
|
217
|
-
* also creates a session. As a result, each session is "associated"
|
|
218
|
-
* with a single dialog - the one which resulted in its creation. If an
|
|
219
|
-
* initial INVITE generates a non-2xx final response, that terminates
|
|
220
|
-
* all sessions (if any) and all dialogs (if any) that were created
|
|
221
|
-
* through responses to the request. By virtue of completing the
|
|
222
|
-
* transaction, a non-2xx final response also prevents further sessions
|
|
223
|
-
* from being created as a result of the INVITE. The BYE request is
|
|
224
|
-
* used to terminate a specific session or attempted session. In this
|
|
225
|
-
* case, the specific session is the one with the peer UA on the other
|
|
226
|
-
* side of the dialog. When a BYE is received on a dialog, any session
|
|
227
|
-
* associated with that dialog SHOULD terminate. A UA MUST NOT send a
|
|
228
|
-
* BYE outside of a dialog. The caller's UA MAY send a BYE for either
|
|
229
|
-
* confirmed or early dialogs, and the callee's UA MAY send a BYE on
|
|
230
|
-
* confirmed dialogs, but MUST NOT send a BYE on early dialogs.
|
|
231
|
-
*
|
|
232
|
-
* However, the callee's UA MUST NOT send a BYE on a confirmed dialog
|
|
233
|
-
* until it has received an ACK for its 2xx response or until the server
|
|
234
|
-
* transaction times out. If no SIP extensions have defined other
|
|
235
|
-
* application layer states associated with the dialog, the BYE also
|
|
236
|
-
* terminates the dialog.
|
|
237
|
-
*
|
|
238
|
-
* https://tools.ietf.org/html/rfc3261#section-15
|
|
239
|
-
* FIXME: Make these proper Exceptions...
|
|
240
|
-
* @param options - BYE options bucket.
|
|
241
|
-
* @returns
|
|
242
|
-
* Throws `Error` if callee's UA attempts a BYE on an early dialog.
|
|
243
|
-
* Throws `Error` if callee's UA attempts a BYE on a confirmed dialog
|
|
244
|
-
* while it's waiting on the ACK for its 2xx response.
|
|
245
|
-
*/
|
|
246
|
-
public bye(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingByeRequest {
|
|
247
|
-
this.logger.log(`INVITE dialog ${this.id} sending BYE request`);
|
|
248
|
-
|
|
249
|
-
// The caller's UA MAY send a BYE for either
|
|
250
|
-
// confirmed or early dialogs, and the callee's UA MAY send a BYE on
|
|
251
|
-
// confirmed dialogs, but MUST NOT send a BYE on early dialogs.
|
|
252
|
-
//
|
|
253
|
-
// However, the callee's UA MUST NOT send a BYE on a confirmed dialog
|
|
254
|
-
// until it has received an ACK for its 2xx response or until the server
|
|
255
|
-
// transaction times out.
|
|
256
|
-
// https://tools.ietf.org/html/rfc3261#section-15
|
|
257
|
-
if (this.initialTransaction instanceof InviteServerTransaction) {
|
|
258
|
-
if (this.early) {
|
|
259
|
-
// FIXME: TODO: This should throw a proper exception.
|
|
260
|
-
throw new Error("UAS MUST NOT send a BYE on early dialogs.");
|
|
261
|
-
}
|
|
262
|
-
if (this.ackWait && this.initialTransaction.state !== TransactionState.Terminated) {
|
|
263
|
-
// FIXME: TODO: This should throw a proper exception.
|
|
264
|
-
throw new Error(
|
|
265
|
-
"UAS MUST NOT send a BYE on a confirmed dialog " +
|
|
266
|
-
"until it has received an ACK for its 2xx response " +
|
|
267
|
-
"or until the server transaction times out."
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// A BYE request is constructed as would any other request within a
|
|
273
|
-
// dialog, as described in Section 12.
|
|
274
|
-
//
|
|
275
|
-
// Once the BYE is constructed, the UAC core creates a new non-INVITE
|
|
276
|
-
// client transaction, and passes it the BYE request. The UAC MUST
|
|
277
|
-
// consider the session terminated (and therefore stop sending or
|
|
278
|
-
// listening for media) as soon as the BYE request is passed to the
|
|
279
|
-
// client transaction. If the response for the BYE is a 481
|
|
280
|
-
// (Call/Transaction Does Not Exist) or a 408 (Request Timeout) or no
|
|
281
|
-
// response at all is received for the BYE (that is, a timeout is
|
|
282
|
-
// returned by the client transaction), the UAC MUST consider the
|
|
283
|
-
// session and the dialog terminated.
|
|
284
|
-
// https://tools.ietf.org/html/rfc3261#section-15.1.1
|
|
285
|
-
return new ByeUserAgentClient(this, delegate, options);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* An INFO request can be associated with an Info Package (see
|
|
290
|
-
* Section 5), or associated with a legacy INFO usage (see Section 2).
|
|
291
|
-
*
|
|
292
|
-
* The construction of the INFO request is the same as any other
|
|
293
|
-
* non-target refresh request within an existing invite dialog usage as
|
|
294
|
-
* described in Section 12.2 of RFC 3261.
|
|
295
|
-
* https://tools.ietf.org/html/rfc6086#section-4.2.1
|
|
296
|
-
* @param options - Options bucket.
|
|
297
|
-
*/
|
|
298
|
-
public info(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingInfoRequest {
|
|
299
|
-
this.logger.log(`INVITE dialog ${this.id} sending INFO request`);
|
|
300
|
-
if (this.early) {
|
|
301
|
-
// FIXME: TODO: This should throw a proper exception.
|
|
302
|
-
throw new Error("Dialog not confirmed.");
|
|
303
|
-
}
|
|
304
|
-
return new InfoUserAgentClient(this, delegate, options);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Modifying an Existing Session
|
|
309
|
-
*
|
|
310
|
-
* A successful INVITE request (see Section 13) establishes both a
|
|
311
|
-
* dialog between two user agents and a session using the offer-answer
|
|
312
|
-
* model. Section 12 explains how to modify an existing dialog using a
|
|
313
|
-
* target refresh request (for example, changing the remote target URI
|
|
314
|
-
* of the dialog). This section describes how to modify the actual
|
|
315
|
-
* session. This modification can involve changing addresses or ports,
|
|
316
|
-
* adding a media stream, deleting a media stream, and so on. This is
|
|
317
|
-
* accomplished by sending a new INVITE request within the same dialog
|
|
318
|
-
* that established the session. An INVITE request sent within an
|
|
319
|
-
* existing dialog is known as a re-INVITE.
|
|
320
|
-
*
|
|
321
|
-
* Note that a single re-INVITE can modify the dialog and the
|
|
322
|
-
* parameters of the session at the same time.
|
|
323
|
-
*
|
|
324
|
-
* Either the caller or callee can modify an existing session.
|
|
325
|
-
* https://tools.ietf.org/html/rfc3261#section-14
|
|
326
|
-
* @param options - Options bucket
|
|
327
|
-
*/
|
|
328
|
-
public invite(delegate?: OutgoingInviteRequestDelegate, options?: RequestOptions): OutgoingInviteRequest {
|
|
329
|
-
this.logger.log(`INVITE dialog ${this.id} sending INVITE request`);
|
|
330
|
-
if (this.early) {
|
|
331
|
-
// FIXME: TODO: This should throw a proper exception.
|
|
332
|
-
throw new Error("Dialog not confirmed.");
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Note that a UAC MUST NOT initiate a new INVITE transaction within a
|
|
336
|
-
// dialog while another INVITE transaction is in progress in either
|
|
337
|
-
// direction.
|
|
338
|
-
//
|
|
339
|
-
// 1. If there is an ongoing INVITE client transaction, the TU MUST
|
|
340
|
-
// wait until the transaction reaches the completed or terminated
|
|
341
|
-
// state before initiating the new INVITE.
|
|
342
|
-
//
|
|
343
|
-
// 2. If there is an ongoing INVITE server transaction, the TU MUST
|
|
344
|
-
// wait until the transaction reaches the confirmed or terminated
|
|
345
|
-
// state before initiating the new INVITE.
|
|
346
|
-
//
|
|
347
|
-
// However, a UA MAY initiate a regular transaction while an INVITE
|
|
348
|
-
// transaction is in progress. A UA MAY also initiate an INVITE
|
|
349
|
-
// transaction while a regular transaction is in progress.
|
|
350
|
-
// https://tools.ietf.org/html/rfc3261#section-14.1
|
|
351
|
-
if (this.reinviteUserAgentClient) {
|
|
352
|
-
// FIXME: TODO: This should throw a proper exception.
|
|
353
|
-
throw new Error("There is an ongoing re-INVITE client transaction.");
|
|
354
|
-
}
|
|
355
|
-
if (this.reinviteUserAgentServer) {
|
|
356
|
-
// FIXME: TODO: This should throw a proper exception.
|
|
357
|
-
throw new Error("There is an ongoing re-INVITE server transaction.");
|
|
358
|
-
}
|
|
359
|
-
return new ReInviteUserAgentClient(this, delegate, options);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* A UAC MAY associate a MESSAGE request with an existing dialog. If a
|
|
364
|
-
* MESSAGE request is sent within a dialog, it is "associated" with any
|
|
365
|
-
* media session or sessions associated with that dialog.
|
|
366
|
-
* https://tools.ietf.org/html/rfc3428#section-4
|
|
367
|
-
* @param options - Options bucket.
|
|
368
|
-
*/
|
|
369
|
-
public message(delegate: OutgoingRequestDelegate, options?: RequestOptions): OutgoingMessageRequest {
|
|
370
|
-
this.logger.log(`INVITE dialog ${this.id} sending MESSAGE request`);
|
|
371
|
-
if (this.early) {
|
|
372
|
-
// FIXME: TODO: This should throw a proper exception.
|
|
373
|
-
throw new Error("Dialog not confirmed.");
|
|
374
|
-
}
|
|
375
|
-
const message = this.createOutgoingRequestMessage(C.MESSAGE, options);
|
|
376
|
-
return new MessageUserAgentClient(this.core, message, delegate);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* The NOTIFY mechanism defined in [2] MUST be used to inform the agent
|
|
381
|
-
* sending the REFER of the status of the reference.
|
|
382
|
-
* https://tools.ietf.org/html/rfc3515#section-2.4.4
|
|
383
|
-
* @param options - Options bucket.
|
|
384
|
-
*/
|
|
385
|
-
public notify(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingNotifyRequest {
|
|
386
|
-
this.logger.log(`INVITE dialog ${this.id} sending NOTIFY request`);
|
|
387
|
-
if (this.early) {
|
|
388
|
-
// FIXME: TODO: This should throw a proper exception.
|
|
389
|
-
throw new Error("Dialog not confirmed.");
|
|
390
|
-
}
|
|
391
|
-
return new NotifyUserAgentClient(this, delegate, options);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Assuming the response is to be transmitted reliably, the UAC MUST
|
|
396
|
-
* create a new request with method PRACK. This request is sent within
|
|
397
|
-
* the dialog associated with the provisional response (indeed, the
|
|
398
|
-
* provisional response may have created the dialog). PRACK requests
|
|
399
|
-
* MAY contain bodies, which are interpreted according to their type and
|
|
400
|
-
* disposition.
|
|
401
|
-
* https://tools.ietf.org/html/rfc3262#section-4
|
|
402
|
-
* @param options - Options bucket.
|
|
403
|
-
*/
|
|
404
|
-
public prack(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingPrackRequest {
|
|
405
|
-
this.logger.log(`INVITE dialog ${this.id} sending PRACK request`);
|
|
406
|
-
return new PrackUserAgentClient(this, delegate, options);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* REFER is a SIP request and is constructed as defined in [1]. A REFER
|
|
411
|
-
* request MUST contain exactly one Refer-To header field value.
|
|
412
|
-
* https://tools.ietf.org/html/rfc3515#section-2.4.1
|
|
413
|
-
* @param options - Options bucket.
|
|
414
|
-
*/
|
|
415
|
-
public refer(delegate?: OutgoingRequestDelegate, options?: RequestOptions): OutgoingReferRequest {
|
|
416
|
-
this.logger.log(`INVITE dialog ${this.id} sending REFER request`);
|
|
417
|
-
if (this.early) {
|
|
418
|
-
// FIXME: TODO: This should throw a proper exception.
|
|
419
|
-
throw new Error("Dialog not confirmed.");
|
|
420
|
-
}
|
|
421
|
-
// FIXME: TODO: Validate Refer-To header field value.
|
|
422
|
-
return new ReferUserAgentClient(this, delegate, options);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Requests sent within a dialog, as any other requests, are atomic. If
|
|
427
|
-
* a particular request is accepted by the UAS, all the state changes
|
|
428
|
-
* associated with it are performed. If the request is rejected, none
|
|
429
|
-
* of the state changes are performed.
|
|
430
|
-
* https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
431
|
-
* @param message - Incoming request message within this dialog.
|
|
432
|
-
*/
|
|
433
|
-
public receiveRequest(message: IncomingRequestMessage): void {
|
|
434
|
-
this.logger.log(`INVITE dialog ${this.id} received ${message.method} request`);
|
|
435
|
-
|
|
436
|
-
// Response retransmissions cease when an ACK request for the
|
|
437
|
-
// response is received. This is independent of whatever transport
|
|
438
|
-
// protocols are used to send the response.
|
|
439
|
-
// https://tools.ietf.org/html/rfc6026#section-8.1
|
|
440
|
-
if (message.method === C.ACK) {
|
|
441
|
-
// If ackWait is true, then this is the ACK to the initial INVITE,
|
|
442
|
-
// otherwise this is an ACK to an in dialog INVITE. In either case,
|
|
443
|
-
// guard to make sure the sequence number of the ACK matches the INVITE.
|
|
444
|
-
if (this.ackWait) {
|
|
445
|
-
if (this.initialTransaction instanceof InviteClientTransaction) {
|
|
446
|
-
this.logger.warn(`INVITE dialog ${this.id} received unexpected ${message.method} request, dropping.`);
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
if (this.initialTransaction.request.cseq !== message.cseq) {
|
|
450
|
-
this.logger.warn(`INVITE dialog ${this.id} received unexpected ${message.method} request, dropping.`);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
// Update before the delegate has a chance to handle the
|
|
454
|
-
// message as delegate may callback into this dialog.
|
|
455
|
-
this.ackWait = false;
|
|
456
|
-
} else {
|
|
457
|
-
if (!this.reinviteUserAgentServer) {
|
|
458
|
-
this.logger.warn(`INVITE dialog ${this.id} received unexpected ${message.method} request, dropping.`);
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
if (this.reinviteUserAgentServer.transaction.request.cseq !== message.cseq) {
|
|
462
|
-
this.logger.warn(`INVITE dialog ${this.id} received unexpected ${message.method} request, dropping.`);
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
this.reinviteUserAgentServer = undefined;
|
|
466
|
-
}
|
|
467
|
-
this.signalingStateTransition(message);
|
|
468
|
-
if (this.delegate && this.delegate.onAck) {
|
|
469
|
-
const promiseOrVoid = this.delegate.onAck({ message });
|
|
470
|
-
if (promiseOrVoid instanceof Promise) {
|
|
471
|
-
this.ackProcessing = true; // make sure this is always reset to false
|
|
472
|
-
promiseOrVoid.then(() => (this.ackProcessing = false)).catch(() => (this.ackProcessing = false));
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// Request within a dialog out of sequence guard.
|
|
479
|
-
// https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
480
|
-
if (!this.sequenceGuard(message)) {
|
|
481
|
-
this.logger.log(`INVITE dialog ${this.id} rejected out of order ${message.method} request.`);
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// Request within a dialog common processing.
|
|
486
|
-
// https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
487
|
-
super.receiveRequest(message);
|
|
488
|
-
|
|
489
|
-
// Handle various INVITE related cross-over, glare and race conditions
|
|
490
|
-
if (message.method === C.INVITE) {
|
|
491
|
-
// Hopefully this message is helpful...
|
|
492
|
-
const warning = (): void => {
|
|
493
|
-
const reason = this.ackWait ? "waiting for initial ACK" : "processing initial ACK";
|
|
494
|
-
this.logger.warn(`INVITE dialog ${this.id} received re-INVITE while ${reason}`);
|
|
495
|
-
let msg = "RFC 5407 suggests the following to avoid this race condition... ";
|
|
496
|
-
msg += " Note: Implementation issues are outside the scope of this document,";
|
|
497
|
-
msg += " but the following tip is provided for avoiding race conditions of";
|
|
498
|
-
msg += " this type. The caller can delay sending re-INVITE F6 for some period";
|
|
499
|
-
msg += " of time (2 seconds, perhaps), after which the caller can reasonably";
|
|
500
|
-
msg += " assume that its ACK has been received. Implementors can decouple the";
|
|
501
|
-
msg += " actions of the user (e.g., pressing the hold button) from the actions";
|
|
502
|
-
msg += " of the protocol (the sending of re-INVITE F6), so that the UA can";
|
|
503
|
-
msg += " behave like this. In this case, it is the implementor's choice as to";
|
|
504
|
-
msg += " how long to wait. In most cases, such an implementation may be";
|
|
505
|
-
msg += " useful to prevent the type of race condition shown in this section.";
|
|
506
|
-
msg += " This document expresses no preference about whether or not they";
|
|
507
|
-
msg += " should wait for an ACK to be delivered. After considering the impact";
|
|
508
|
-
msg += " on user experience, implementors should decide whether or not to wait";
|
|
509
|
-
msg += " for a while, because the user experience depends on the";
|
|
510
|
-
msg += " implementation and has no direct bearing on protocol behavior.";
|
|
511
|
-
this.logger.warn(msg);
|
|
512
|
-
return; // drop re-INVITE request message
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
// A UAS that receives a second INVITE before it sends the final
|
|
516
|
-
// response to a first INVITE with a lower CSeq sequence number on the
|
|
517
|
-
// same dialog MUST return a 500 (Server Internal Error) response to the
|
|
518
|
-
// second INVITE and MUST include a Retry-After header field with a
|
|
519
|
-
// randomly chosen value of between 0 and 10 seconds.
|
|
520
|
-
// https://tools.ietf.org/html/rfc3261#section-14.2
|
|
521
|
-
const retryAfter = Math.floor(Math.random() * 10) + 1;
|
|
522
|
-
const extraHeaders = [`Retry-After: ${retryAfter}`];
|
|
523
|
-
|
|
524
|
-
// There may be ONLY ONE offer/answer negotiation in progress for a
|
|
525
|
-
// single dialog at any point in time. Section 4 explains how to ensure
|
|
526
|
-
// this.
|
|
527
|
-
// https://tools.ietf.org/html/rfc6337#section-2.2
|
|
528
|
-
if (this.ackProcessing) {
|
|
529
|
-
// UAS-IsI: While an INVITE server transaction is incomplete or ACK
|
|
530
|
-
// transaction associated with an offer/answer is incomplete,
|
|
531
|
-
// a UA must reject another INVITE request with a 500
|
|
532
|
-
// response.
|
|
533
|
-
// https://tools.ietf.org/html/rfc6337#section-4.3
|
|
534
|
-
this.core.replyStateless(message, { statusCode: 500, extraHeaders });
|
|
535
|
-
warning();
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
// 3.1.4. Callee Receives re-INVITE (Established State) While in the
|
|
540
|
-
// Moratorium State (Case 1)
|
|
541
|
-
// https://tools.ietf.org/html/rfc5407#section-3.1.4
|
|
542
|
-
// 3.1.5. Callee Receives re-INVITE (Established State) While in the
|
|
543
|
-
// Moratorium State (Case 2)
|
|
544
|
-
// https://tools.ietf.org/html/rfc5407#section-3.1.5
|
|
545
|
-
if (this.ackWait && this.signalingState !== SignalingState.Stable) {
|
|
546
|
-
// This scenario is basically the same as that of Section 3.1.4, but
|
|
547
|
-
// differs in sending an offer in the 200 and an answer in the ACK. In
|
|
548
|
-
// contrast to the previous case, the offer in the 200 (F3) and the
|
|
549
|
-
// offer in the re-INVITE (F6) collide with each other.
|
|
550
|
-
//
|
|
551
|
-
// Bob sends a 491 to the re-INVITE (F6) since he is not able to
|
|
552
|
-
// properly handle a new request until he receives an answer. (Note:
|
|
553
|
-
// 500 with a Retry-After header may be returned if the 491 response is
|
|
554
|
-
// understood to indicate request collision. However, 491 is
|
|
555
|
-
// recommended here because 500 applies to so many cases that it is
|
|
556
|
-
// difficult to determine what the real problem was.)
|
|
557
|
-
// https://tools.ietf.org/html/rfc5407#section-3.1.5
|
|
558
|
-
|
|
559
|
-
// UAS-IsI: While an INVITE server transaction is incomplete or ACK
|
|
560
|
-
// transaction associated with an offer/answer is incomplete,
|
|
561
|
-
// a UA must reject another INVITE request with a 500
|
|
562
|
-
// response.
|
|
563
|
-
// https://tools.ietf.org/html/rfc6337#section-4.3
|
|
564
|
-
this.core.replyStateless(message, { statusCode: 500, extraHeaders });
|
|
565
|
-
warning();
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// A UAS that receives a second INVITE before it sends the final
|
|
570
|
-
// response to a first INVITE with a lower CSeq sequence number on the
|
|
571
|
-
// same dialog MUST return a 500 (Server Internal Error) response to the
|
|
572
|
-
// second INVITE and MUST include a Retry-After header field with a
|
|
573
|
-
// randomly chosen value of between 0 and 10 seconds.
|
|
574
|
-
// https://tools.ietf.org/html/rfc3261#section-14.2
|
|
575
|
-
if (this.reinviteUserAgentServer) {
|
|
576
|
-
this.core.replyStateless(message, { statusCode: 500, extraHeaders });
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// A UAS that receives an INVITE on a dialog while an INVITE it had sent
|
|
581
|
-
// on that dialog is in progress MUST return a 491 (Request Pending)
|
|
582
|
-
// response to the received INVITE.
|
|
583
|
-
// https://tools.ietf.org/html/rfc3261#section-14.2
|
|
584
|
-
if (this.reinviteUserAgentClient) {
|
|
585
|
-
this.core.replyStateless(message, { statusCode: 491 });
|
|
586
|
-
return;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
// Requests within a dialog MAY contain Record-Route and Contact header
|
|
591
|
-
// fields. However, these requests do not cause the dialog's route set
|
|
592
|
-
// to be modified, although they may modify the remote target URI.
|
|
593
|
-
// Specifically, requests that are not target refresh requests do not
|
|
594
|
-
// modify the dialog's remote target URI, and requests that are target
|
|
595
|
-
// refresh requests do. For dialogs that have been established with an
|
|
596
|
-
// INVITE, the only target refresh request defined is re-INVITE (see
|
|
597
|
-
// Section 14). Other extensions may define different target refresh
|
|
598
|
-
// requests for dialogs established in other ways.
|
|
599
|
-
//
|
|
600
|
-
// Note that an ACK is NOT a target refresh request.
|
|
601
|
-
//
|
|
602
|
-
// Target refresh requests only update the dialog's remote target URI,
|
|
603
|
-
// and not the route set formed from the Record-Route. Updating the
|
|
604
|
-
// latter would introduce severe backwards compatibility problems with
|
|
605
|
-
// RFC 2543-compliant systems.
|
|
606
|
-
// https://tools.ietf.org/html/rfc3261#section-15
|
|
607
|
-
if (message.method === C.INVITE) {
|
|
608
|
-
// FIXME: parser needs to be typed...
|
|
609
|
-
const contact = message.parseHeader("contact");
|
|
610
|
-
if (!contact) {
|
|
611
|
-
// TODO: Review to make sure this will never happen
|
|
612
|
-
throw new Error("Contact undefined.");
|
|
613
|
-
}
|
|
614
|
-
if (!(contact instanceof NameAddrHeader)) {
|
|
615
|
-
throw new Error("Contact not instance of NameAddrHeader.");
|
|
616
|
-
}
|
|
617
|
-
this.dialogState.remoteTarget = contact.uri;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
// Switch on method and then delegate.
|
|
621
|
-
switch (message.method) {
|
|
622
|
-
case C.BYE:
|
|
623
|
-
// A UAS core receiving a BYE request for an existing dialog MUST follow
|
|
624
|
-
// the procedures of Section 12.2.2 to process the request. Once done,
|
|
625
|
-
// the UAS SHOULD terminate the session (and therefore stop sending and
|
|
626
|
-
// listening for media). The only case where it can elect not to are
|
|
627
|
-
// multicast sessions, where participation is possible even if the other
|
|
628
|
-
// participant in the dialog has terminated its involvement in the
|
|
629
|
-
// session. Whether or not it ends its participation on the session,
|
|
630
|
-
// the UAS core MUST generate a 2xx response to the BYE, and MUST pass
|
|
631
|
-
// that to the server transaction for transmission.
|
|
632
|
-
//
|
|
633
|
-
// The UAS MUST still respond to any pending requests received for that
|
|
634
|
-
// dialog. It is RECOMMENDED that a 487 (Request Terminated) response
|
|
635
|
-
// be generated to those pending requests.
|
|
636
|
-
// https://tools.ietf.org/html/rfc3261#section-15.1.2
|
|
637
|
-
{
|
|
638
|
-
const uas = new ByeUserAgentServer(this, message);
|
|
639
|
-
this.delegate && this.delegate.onBye ? this.delegate.onBye(uas) : uas.accept();
|
|
640
|
-
this.dispose();
|
|
641
|
-
}
|
|
642
|
-
break;
|
|
643
|
-
case C.INFO:
|
|
644
|
-
// If a UA receives an INFO request associated with an Info Package that
|
|
645
|
-
// the UA has not indicated willingness to receive, the UA MUST send a
|
|
646
|
-
// 469 (Bad Info Package) response (see Section 11.6), which contains a
|
|
647
|
-
// Recv-Info header field with Info Packages for which the UA is willing
|
|
648
|
-
// to receive INFO requests.
|
|
649
|
-
{
|
|
650
|
-
const uas = new InfoUserAgentServer(this, message);
|
|
651
|
-
this.delegate && this.delegate.onInfo
|
|
652
|
-
? this.delegate.onInfo(uas)
|
|
653
|
-
: uas.reject({
|
|
654
|
-
statusCode: 469,
|
|
655
|
-
extraHeaders: ["Recv-Info :"]
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
break;
|
|
659
|
-
case C.INVITE:
|
|
660
|
-
// If the new session description is not acceptable, the UAS can reject
|
|
661
|
-
// it by returning a 488 (Not Acceptable Here) response for the re-
|
|
662
|
-
// INVITE. This response SHOULD include a Warning header field.
|
|
663
|
-
// https://tools.ietf.org/html/rfc3261#section-14.2
|
|
664
|
-
{
|
|
665
|
-
const uas = new ReInviteUserAgentServer(this, message);
|
|
666
|
-
this.signalingStateTransition(message);
|
|
667
|
-
this.delegate && this.delegate.onInvite ? this.delegate.onInvite(uas) : uas.reject({ statusCode: 488 }); // TODO: Warning header field.
|
|
668
|
-
}
|
|
669
|
-
break;
|
|
670
|
-
case C.MESSAGE:
|
|
671
|
-
{
|
|
672
|
-
const uas = new MessageUserAgentServer(this.core, message);
|
|
673
|
-
this.delegate && this.delegate.onMessage ? this.delegate.onMessage(uas) : uas.accept();
|
|
674
|
-
}
|
|
675
|
-
break;
|
|
676
|
-
case C.NOTIFY:
|
|
677
|
-
// https://tools.ietf.org/html/rfc3515#section-2.4.4
|
|
678
|
-
{
|
|
679
|
-
const uas = new NotifyUserAgentServer(this, message);
|
|
680
|
-
this.delegate && this.delegate.onNotify ? this.delegate.onNotify(uas) : uas.accept();
|
|
681
|
-
}
|
|
682
|
-
break;
|
|
683
|
-
case C.PRACK:
|
|
684
|
-
// https://tools.ietf.org/html/rfc3262#section-4
|
|
685
|
-
{
|
|
686
|
-
const uas = new PrackUserAgentServer(this, message);
|
|
687
|
-
this.delegate && this.delegate.onPrack ? this.delegate.onPrack(uas) : uas.accept();
|
|
688
|
-
}
|
|
689
|
-
break;
|
|
690
|
-
case C.REFER:
|
|
691
|
-
// https://tools.ietf.org/html/rfc3515#section-2.4.2
|
|
692
|
-
{
|
|
693
|
-
const uas = new ReferUserAgentServer(this, message);
|
|
694
|
-
this.delegate && this.delegate.onRefer ? this.delegate.onRefer(uas) : uas.reject();
|
|
695
|
-
}
|
|
696
|
-
break;
|
|
697
|
-
default:
|
|
698
|
-
{
|
|
699
|
-
this.logger.log(`INVITE dialog ${this.id} received unimplemented ${message.method} request`);
|
|
700
|
-
this.core.replyStateless(message, { statusCode: 501 });
|
|
701
|
-
}
|
|
702
|
-
break;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* Guard against out of order reliable provisional responses and retransmissions.
|
|
708
|
-
* Returns false if the response should be discarded, otherwise true.
|
|
709
|
-
* @param message - Incoming response message within this dialog.
|
|
710
|
-
*/
|
|
711
|
-
public reliableSequenceGuard(message: IncomingResponseMessage): boolean {
|
|
712
|
-
const statusCode = message.statusCode;
|
|
713
|
-
if (!statusCode) {
|
|
714
|
-
throw new Error("Status code undefined");
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
if (statusCode > 100 && statusCode < 200) {
|
|
718
|
-
// If a provisional response is received for an initial request, and
|
|
719
|
-
// that response contains a Require header field containing the option
|
|
720
|
-
// tag 100rel, the response is to be sent reliably. If the response is
|
|
721
|
-
// a 100 (Trying) (as opposed to 101 to 199), this option tag MUST be
|
|
722
|
-
// ignored, and the procedures below MUST NOT be used.
|
|
723
|
-
// https://tools.ietf.org/html/rfc3262#section-4
|
|
724
|
-
const requireHeader = message.getHeader("require");
|
|
725
|
-
const rseqHeader = message.getHeader("rseq");
|
|
726
|
-
const rseq = requireHeader && requireHeader.includes("100rel") && rseqHeader ? Number(rseqHeader) : undefined;
|
|
727
|
-
if (rseq) {
|
|
728
|
-
// Handling of subsequent reliable provisional responses for the same
|
|
729
|
-
// initial request follows the same rules as above, with the following
|
|
730
|
-
// difference: reliable provisional responses are guaranteed to be in
|
|
731
|
-
// order. As a result, if the UAC receives another reliable provisional
|
|
732
|
-
// response to the same request, and its RSeq value is not one higher
|
|
733
|
-
// than the value of the sequence number, that response MUST NOT be
|
|
734
|
-
// acknowledged with a PRACK, and MUST NOT be processed further by the
|
|
735
|
-
// UAC. An implementation MAY discard the response, or MAY cache the
|
|
736
|
-
// response in the hopes of receiving the missing responses.
|
|
737
|
-
// https://tools.ietf.org/html/rfc3262#section-4
|
|
738
|
-
if (this.rseq && this.rseq + 1 !== rseq) {
|
|
739
|
-
return false;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
// Once a reliable provisional response is received, retransmissions of
|
|
743
|
-
// that response MUST be discarded. A response is a retransmission when
|
|
744
|
-
// its dialog ID, CSeq, and RSeq match the original response. The UAC
|
|
745
|
-
// MUST maintain a sequence number that indicates the most recently
|
|
746
|
-
// received in-order reliable provisional response for the initial
|
|
747
|
-
// request. This sequence number MUST be maintained until a final
|
|
748
|
-
// response is received for the initial request. Its value MUST be
|
|
749
|
-
// initialized to the RSeq header field in the first reliable
|
|
750
|
-
// provisional response received for the initial request.
|
|
751
|
-
// https://tools.ietf.org/html/rfc3262#section-4
|
|
752
|
-
this.rseq = this.rseq ? this.rseq + 1 : rseq;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
return true;
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* If not in a stable signaling state, rollback to prior stable signaling state.
|
|
761
|
-
*/
|
|
762
|
-
public signalingStateRollback(): void {
|
|
763
|
-
if (
|
|
764
|
-
this._signalingState === SignalingState.HaveLocalOffer ||
|
|
765
|
-
this.signalingState === SignalingState.HaveRemoteOffer
|
|
766
|
-
) {
|
|
767
|
-
if (this._rollbackOffer && this._rollbackAnswer) {
|
|
768
|
-
this._signalingState = SignalingState.Stable;
|
|
769
|
-
this._offer = this._rollbackOffer;
|
|
770
|
-
this._answer = this._rollbackAnswer;
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* Update the signaling state of the dialog.
|
|
777
|
-
* @param message - The message to base the update off of.
|
|
778
|
-
*/
|
|
779
|
-
public signalingStateTransition(
|
|
780
|
-
message: IncomingRequestMessage | IncomingResponseMessage | OutgoingRequestMessage | Body
|
|
781
|
-
): void {
|
|
782
|
-
const body = getBody(message);
|
|
783
|
-
|
|
784
|
-
// No body, no session. No, woman, no cry.
|
|
785
|
-
if (!body || body.contentDisposition !== "session") {
|
|
786
|
-
return;
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
// We've got an existing offer and answer which we may wish to rollback to
|
|
790
|
-
if (this._signalingState === SignalingState.Stable) {
|
|
791
|
-
this._rollbackOffer = this._offer;
|
|
792
|
-
this._rollbackAnswer = this._answer;
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
// We're in UAS role, receiving incoming request with session description
|
|
796
|
-
if (message instanceof IncomingRequestMessage) {
|
|
797
|
-
switch (this._signalingState) {
|
|
798
|
-
case SignalingState.Initial:
|
|
799
|
-
case SignalingState.Stable:
|
|
800
|
-
this._signalingState = SignalingState.HaveRemoteOffer;
|
|
801
|
-
this._offer = body;
|
|
802
|
-
this._answer = undefined;
|
|
803
|
-
break;
|
|
804
|
-
case SignalingState.HaveLocalOffer:
|
|
805
|
-
this._signalingState = SignalingState.Stable;
|
|
806
|
-
this._answer = body;
|
|
807
|
-
break;
|
|
808
|
-
case SignalingState.HaveRemoteOffer:
|
|
809
|
-
// You cannot make a new offer while one is in progress.
|
|
810
|
-
// https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
811
|
-
// FIXME: What to do here?
|
|
812
|
-
break;
|
|
813
|
-
case SignalingState.Closed:
|
|
814
|
-
break;
|
|
815
|
-
default:
|
|
816
|
-
throw new Error("Unexpected signaling state.");
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
// We're in UAC role, receiving incoming response with session description
|
|
821
|
-
if (message instanceof IncomingResponseMessage) {
|
|
822
|
-
switch (this._signalingState) {
|
|
823
|
-
case SignalingState.Initial:
|
|
824
|
-
case SignalingState.Stable:
|
|
825
|
-
this._signalingState = SignalingState.HaveRemoteOffer;
|
|
826
|
-
this._offer = body;
|
|
827
|
-
this._answer = undefined;
|
|
828
|
-
break;
|
|
829
|
-
case SignalingState.HaveLocalOffer:
|
|
830
|
-
this._signalingState = SignalingState.Stable;
|
|
831
|
-
this._answer = body;
|
|
832
|
-
break;
|
|
833
|
-
case SignalingState.HaveRemoteOffer:
|
|
834
|
-
// You cannot make a new offer while one is in progress.
|
|
835
|
-
// https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
836
|
-
// FIXME: What to do here?
|
|
837
|
-
break;
|
|
838
|
-
case SignalingState.Closed:
|
|
839
|
-
break;
|
|
840
|
-
default:
|
|
841
|
-
throw new Error("Unexpected signaling state.");
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
// We're in UAC role, sending outgoing request with session description
|
|
846
|
-
if (message instanceof OutgoingRequestMessage) {
|
|
847
|
-
switch (this._signalingState) {
|
|
848
|
-
case SignalingState.Initial:
|
|
849
|
-
case SignalingState.Stable:
|
|
850
|
-
this._signalingState = SignalingState.HaveLocalOffer;
|
|
851
|
-
this._offer = body;
|
|
852
|
-
this._answer = undefined;
|
|
853
|
-
break;
|
|
854
|
-
case SignalingState.HaveLocalOffer:
|
|
855
|
-
// You cannot make a new offer while one is in progress.
|
|
856
|
-
// https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
857
|
-
// FIXME: What to do here?
|
|
858
|
-
break;
|
|
859
|
-
case SignalingState.HaveRemoteOffer:
|
|
860
|
-
this._signalingState = SignalingState.Stable;
|
|
861
|
-
this._answer = body;
|
|
862
|
-
break;
|
|
863
|
-
case SignalingState.Closed:
|
|
864
|
-
break;
|
|
865
|
-
default:
|
|
866
|
-
throw new Error("Unexpected signaling state.");
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
// We're in UAS role, sending outgoing response with session description
|
|
871
|
-
if (isBody(message)) {
|
|
872
|
-
switch (this._signalingState) {
|
|
873
|
-
case SignalingState.Initial:
|
|
874
|
-
case SignalingState.Stable:
|
|
875
|
-
this._signalingState = SignalingState.HaveLocalOffer;
|
|
876
|
-
this._offer = body;
|
|
877
|
-
this._answer = undefined;
|
|
878
|
-
break;
|
|
879
|
-
case SignalingState.HaveLocalOffer:
|
|
880
|
-
// You cannot make a new offer while one is in progress.
|
|
881
|
-
// https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
882
|
-
// FIXME: What to do here?
|
|
883
|
-
break;
|
|
884
|
-
case SignalingState.HaveRemoteOffer:
|
|
885
|
-
this._signalingState = SignalingState.Stable;
|
|
886
|
-
this._answer = body;
|
|
887
|
-
break;
|
|
888
|
-
case SignalingState.Closed:
|
|
889
|
-
break;
|
|
890
|
-
default:
|
|
891
|
-
throw new Error("Unexpected signaling state.");
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
private start2xxRetransmissionTimer(): void {
|
|
897
|
-
if (this.initialTransaction instanceof InviteServerTransaction) {
|
|
898
|
-
const transaction = this.initialTransaction;
|
|
899
|
-
|
|
900
|
-
// Once the response has been constructed, it is passed to the INVITE
|
|
901
|
-
// server transaction. In order to ensure reliable end-to-end
|
|
902
|
-
// transport of the response, it is necessary to periodically pass
|
|
903
|
-
// the response directly to the transport until the ACK arrives. The
|
|
904
|
-
// 2xx response is passed to the transport with an interval that
|
|
905
|
-
// starts at T1 seconds and doubles for each retransmission until it
|
|
906
|
-
// reaches T2 seconds (T1 and T2 are defined in Section 17).
|
|
907
|
-
// Response retransmissions cease when an ACK request for the
|
|
908
|
-
// response is received. This is independent of whatever transport
|
|
909
|
-
// protocols are used to send the response.
|
|
910
|
-
// https://tools.ietf.org/html/rfc6026#section-8.1
|
|
911
|
-
let timeout = Timers.T1;
|
|
912
|
-
const retransmission = (): void => {
|
|
913
|
-
if (!this.ackWait) {
|
|
914
|
-
this.invite2xxTimer = undefined;
|
|
915
|
-
return;
|
|
916
|
-
}
|
|
917
|
-
this.logger.log("No ACK for 2xx response received, attempting retransmission");
|
|
918
|
-
transaction.retransmitAcceptedResponse();
|
|
919
|
-
timeout = Math.min(timeout * 2, Timers.T2);
|
|
920
|
-
this.invite2xxTimer = window.setTimeout(retransmission, timeout);
|
|
921
|
-
};
|
|
922
|
-
this.invite2xxTimer = window.setTimeout(retransmission, timeout);
|
|
923
|
-
|
|
924
|
-
// If the server retransmits the 2xx response for 64*T1 seconds without
|
|
925
|
-
// receiving an ACK, the dialog is confirmed, but the session SHOULD be
|
|
926
|
-
// terminated. This is accomplished with a BYE, as described in Section 15.
|
|
927
|
-
// https://tools.ietf.org/html/rfc3261#section-13.3.1.4
|
|
928
|
-
const stateChanged = (): void => {
|
|
929
|
-
if (transaction.state === TransactionState.Terminated) {
|
|
930
|
-
transaction.removeStateChangeListener(stateChanged);
|
|
931
|
-
if (this.invite2xxTimer) {
|
|
932
|
-
clearTimeout(this.invite2xxTimer);
|
|
933
|
-
this.invite2xxTimer = undefined;
|
|
934
|
-
}
|
|
935
|
-
if (this.ackWait) {
|
|
936
|
-
if (this.delegate && this.delegate.onAckTimeout) {
|
|
937
|
-
this.delegate.onAckTimeout();
|
|
938
|
-
} else {
|
|
939
|
-
this.bye();
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
};
|
|
944
|
-
transaction.addStateChangeListener(stateChanged);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
// FIXME: Refactor
|
|
949
|
-
private startReInvite2xxRetransmissionTimer(): void {
|
|
950
|
-
if (this.reinviteUserAgentServer && this.reinviteUserAgentServer.transaction instanceof InviteServerTransaction) {
|
|
951
|
-
const transaction = this.reinviteUserAgentServer.transaction;
|
|
952
|
-
|
|
953
|
-
// Once the response has been constructed, it is passed to the INVITE
|
|
954
|
-
// server transaction. In order to ensure reliable end-to-end
|
|
955
|
-
// transport of the response, it is necessary to periodically pass
|
|
956
|
-
// the response directly to the transport until the ACK arrives. The
|
|
957
|
-
// 2xx response is passed to the transport with an interval that
|
|
958
|
-
// starts at T1 seconds and doubles for each retransmission until it
|
|
959
|
-
// reaches T2 seconds (T1 and T2 are defined in Section 17).
|
|
960
|
-
// Response retransmissions cease when an ACK request for the
|
|
961
|
-
// response is received. This is independent of whatever transport
|
|
962
|
-
// protocols are used to send the response.
|
|
963
|
-
// https://tools.ietf.org/html/rfc6026#section-8.1
|
|
964
|
-
let timeout = Timers.T1;
|
|
965
|
-
const retransmission = (): void => {
|
|
966
|
-
if (!this.reinviteUserAgentServer) {
|
|
967
|
-
this.invite2xxTimer = undefined;
|
|
968
|
-
return;
|
|
969
|
-
}
|
|
970
|
-
this.logger.log("No ACK for 2xx response received, attempting retransmission");
|
|
971
|
-
transaction.retransmitAcceptedResponse();
|
|
972
|
-
timeout = Math.min(timeout * 2, Timers.T2);
|
|
973
|
-
this.invite2xxTimer = window.setTimeout(retransmission, timeout);
|
|
974
|
-
};
|
|
975
|
-
this.invite2xxTimer = window.setTimeout(retransmission, timeout);
|
|
976
|
-
|
|
977
|
-
// If the server retransmits the 2xx response for 64*T1 seconds without
|
|
978
|
-
// receiving an ACK, the dialog is confirmed, but the session SHOULD be
|
|
979
|
-
// terminated. This is accomplished with a BYE, as described in Section 15.
|
|
980
|
-
// https://tools.ietf.org/html/rfc3261#section-13.3.1.4
|
|
981
|
-
const stateChanged = (): void => {
|
|
982
|
-
if (transaction.state === TransactionState.Terminated) {
|
|
983
|
-
transaction.removeStateChangeListener(stateChanged);
|
|
984
|
-
if (this.invite2xxTimer) {
|
|
985
|
-
clearTimeout(this.invite2xxTimer);
|
|
986
|
-
this.invite2xxTimer = undefined;
|
|
987
|
-
}
|
|
988
|
-
if (this.reinviteUserAgentServer) {
|
|
989
|
-
// FIXME: TODO: What to do here
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
};
|
|
993
|
-
transaction.addStateChangeListener(stateChanged);
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
}
|