diff --git a/CHANGELOG.md b/CHANGELOG.md index 40ebcbafa9..758e05528b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fix `AbortError` when turning video ON in Safari. +- `MessagingSession` reconnects with refreshed endpoint and credentials if needed. `EndpointUrl` on `MessagingSessionConfiguration` is deprecated as it is resolved by calling `getMessagingSessionEndpoint` internally. ## [3.6.0] - 2022-06-23 diff --git a/README.md b/README.md index b20bae41ea..f1dc0c5782 100644 --- a/README.md +++ b/README.md @@ -230,7 +230,7 @@ The value of the MediaRegion parameter in the createMeeting() should ideally be Create a messaging session in your client application to receive messages from Amazon Chime SDK for Messaging. ```js -import { ChimeSDKMessagingClient, GetMessagingSessionEndpointCommand } from '@aws-sdk/client-chime-sdk-messaging'; +import { ChimeSDKMessagingClient } from '@aws-sdk/client-chime-sdk-messaging'; import { ConsoleLogger, @@ -243,11 +243,10 @@ const logger = new ConsoleLogger('SDK', LogLevel.INFO); // You will need AWS credentials configured before calling AWS or Amazon Chime APIs. const chime = new ChimeSDKMessagingClient({ region: 'us-east-1'}); -const endpoint = await chime.send(new GetMessagingSessionEndpointCommand()); const userArn = /* The userArn */; const sessionId = /* The sessionId */; -const configuration = new MessagingSessionConfiguration(userArn, sessionId, endpoint.Endpoint.Url, chime); +const configuration = new MessagingSessionConfiguration(userArn, sessionId, undefined, chime); const messagingSession = new DefaultMessagingSession(configuration, logger); ``` If you would like to enable prefetch feature when connecting to a messaging session, you can follow the code below. diff --git a/demos/browser/app/messagingSession/messagingSession.ts b/demos/browser/app/messagingSession/messagingSession.ts index 3b32ff905c..2757af4d3a 100644 --- a/demos/browser/app/messagingSession/messagingSession.ts +++ b/demos/browser/app/messagingSession/messagingSession.ts @@ -20,7 +20,7 @@ import { Versioning, } from 'amazon-chime-sdk-js'; -import {ChimeSDKMessagingClient, GetMessagingSessionEndpointCommand} from '@aws-sdk/client-chime-sdk-messaging'; +import { ChimeSDKMessagingClient } from '@aws-sdk/client-chime-sdk-messaging'; export class DemoMessagingSessionApp implements MessagingSessionObserver { static readonly BASE_URL: string = [ @@ -57,12 +57,11 @@ export class DemoMessagingSessionApp implements MessagingSessionObserver { try { const response = await this.fetchCredentials(); const chime = new ChimeSDKMessagingClient({ region: 'us-east-1', credentials: response }); - const endpoint = await chime.send(new GetMessagingSessionEndpointCommand()); this.userArn = (document.getElementById('userArn') as HTMLInputElement).value; this.sessionId = (document.getElementById('sessionId') as HTMLInputElement).value; this.prefetchSortByUnread = (document.getElementById('prefetchSortByUnread') as HTMLInputElement).checked; this.prefetchSortByLastMessageTimestamp = (document.getElementById('prefetchSortByLastMessageTimestamp') as HTMLInputElement).checked; - this.configuration = new MessagingSessionConfiguration(this.userArn, this.sessionId, endpoint.Endpoint.Url, chime); + this.configuration = new MessagingSessionConfiguration(this.userArn, this.sessionId, undefined, chime); if (this.prefetchSortByUnread) { this.configuration.prefetchOn = PrefetchOn.Connect; this.configuration.prefetchSortBy = PrefetchSortBy.Unread diff --git a/demos/browser/package-lock.json b/demos/browser/package-lock.json index 6ea46ec874..46838412cf 100644 --- a/demos/browser/package-lock.json +++ b/demos/browser/package-lock.json @@ -46,6 +46,7 @@ "license": "Apache-2.0", "dependencies": { "@aws-crypto/sha256-js": "^2.0.1", + "@aws-sdk/client-chime-sdk-messaging": "^3.0.0", "@aws-sdk/util-hex-encoding": "^3.47.0", "@types/ua-parser-js": "^0.7.35", "detect-browser": "^5.2.0", @@ -8487,6 +8488,7 @@ "version": "file:../..", "requires": { "@aws-crypto/sha256-js": "^2.0.1", + "@aws-sdk/client-chime-sdk-messaging": "^3.0.0", "@aws-sdk/util-hex-encoding": "^3.47.0", "@fluffy-spoon/substitute": "^1.89.0", "@types/chai": "^4.1.7", diff --git a/docs/classes/defaultmessagingsession.html b/docs/classes/defaultmessagingsession.html index 98e12a389f..b0bedd6cfe 100644 --- a/docs/classes/defaultmessagingsession.html +++ b/docs/classes/defaultmessagingsession.html @@ -114,7 +114,7 @@

constructor

  • Parameters

    @@ -153,7 +153,7 @@

    addObserver

    @@ -182,7 +182,7 @@

    forEachObserver

    @@ -230,7 +230,7 @@

    removeObserver

    @@ -259,7 +259,7 @@

    start

    @@ -282,7 +282,7 @@

    stop

    diff --git a/docs/classes/messagingsessionconfiguration.html b/docs/classes/messagingsessionconfiguration.html index 56d26a2ee4..9110d0f08a 100644 --- a/docs/classes/messagingsessionconfiguration.html +++ b/docs/classes/messagingsessionconfiguration.html @@ -127,10 +127,12 @@

    constructor

    Constructs a MessagingSessionConfiguration optionally with userArn, messaging session id, a messaging session - endpoint URL, and the chimeClient. - The messaging session id is to uniquely identify this messaging session for the userArn. - If messaging session id is passed in as null, it will be automatically generated.

    + endpoint URL, and the chimeClient.

    +

    endpointUrl is deprecated and should not be used. Internally it is resolved on connect via chimeClient if undefined, and + always re-resolved on reconnect.

    +

    The messaging session id is to uniquely identify this messaging session for the userArn. + If messaging session id is passed in as null, it will be automatically generated.

    Parameters