Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessagingSession reconnects with refreshed endpoint and credentials if needed #2180

Merged
merged 11 commits into from
Apr 26, 2022
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- `MessagingSession` reconnects with refreshed endpoint and credentials if needed. EndpointUrl on `MessagingSessionConfiguration` is deprecated as it is resolved by calling `getMessagingSessionEndpoint` internally.
- Fix a bug that `remote-inbound-rtp` `RTCStatsReport` and `remote-outbound-rtp` `RTCStatsReport` of "video" `kind` are accidentally filtered.

## [3.0.0] - 2022-03-30
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
```

Expand Down
5 changes: 2 additions & 3 deletions demos/browser/app/messagingSession/messagingSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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 = [
Expand Down Expand Up @@ -54,10 +54,9 @@ 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.configuration = new MessagingSessionConfiguration(this.userArn, this.sessionId, endpoint.Endpoint.Url, chime);
this.configuration = new MessagingSessionConfiguration(this.userArn, this.sessionId, undefined, chime);
this.session = new DefaultMessagingSession(this.configuration, this.logger);
this.session.addObserver(this);
this.session.start();
Expand Down
12 changes: 6 additions & 6 deletions docs/classes/defaultmessagingsession.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L23">src/messagingsession/DefaultMessagingSession.ts:23</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L25">src/messagingsession/DefaultMessagingSession.ts:25</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand Down Expand Up @@ -154,7 +154,7 @@ <h3>add<wbr>Observer</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/messagingsession.html">MessagingSession</a>.<a href="../interfaces/messagingsession.html#addobserver">addObserver</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L53">src/messagingsession/DefaultMessagingSession.ts:53</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L55">src/messagingsession/DefaultMessagingSession.ts:55</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -177,7 +177,7 @@ <h3>for<wbr>Each<wbr>Observer</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L81">src/messagingsession/DefaultMessagingSession.ts:81</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L83">src/messagingsession/DefaultMessagingSession.ts:83</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand Down Expand Up @@ -219,7 +219,7 @@ <h3>remove<wbr>Observer</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/messagingsession.html">MessagingSession</a>.<a href="../interfaces/messagingsession.html#removeobserver">removeObserver</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L58">src/messagingsession/DefaultMessagingSession.ts:58</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L60">src/messagingsession/DefaultMessagingSession.ts:60</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -243,7 +243,7 @@ <h3>start</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/messagingsession.html">MessagingSession</a>.<a href="../interfaces/messagingsession.html#start">start</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L63">src/messagingsession/DefaultMessagingSession.ts:63</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L65">src/messagingsession/DefaultMessagingSession.ts:65</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
Expand All @@ -261,7 +261,7 @@ <h3>stop</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/messagingsession.html">MessagingSession</a>.<a href="../interfaces/messagingsession.html#stop">stop</a></p>
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L71">src/messagingsession/DefaultMessagingSession.ts:71</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/DefaultMessagingSession.ts#L73">src/messagingsession/DefaultMessagingSession.ts:73</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
Expand Down
22 changes: 12 additions & 10 deletions docs/classes/messagingsessionconfiguration.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <h2>Constructors</h2>
<a name="constructor" class="tsd-anchor"></a>
<h3>constructor</h3>
<ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">new <wbr>Messaging<wbr>Session<wbr>Configuration<span class="tsd-signature-symbol">(</span>userArn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, messagingSessionId<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span>, endpointUrl<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, chimeClient<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="messagingsessionconfiguration.html" class="tsd-signature-type">MessagingSessionConfiguration</a></li>
<li class="tsd-signature tsd-kind-icon">new <wbr>Messaging<wbr>Session<wbr>Configuration<span class="tsd-signature-symbol">(</span>userArn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, messagingSessionId<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span>, endpointUrl<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span>, chimeClient<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="messagingsessionconfiguration.html" class="tsd-signature-type">MessagingSessionConfiguration</a></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
Expand All @@ -126,10 +126,12 @@ <h3>constructor</h3>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>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.</p>
endpoint URL, and the chimeClient.</p>
</div>
<p>endpointUrl is deprecated and should not be used. Internally it is resolved on connect via chimeClient if undefined, and
always re-resolved on reconnect.</p>
<p>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.</p>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
Expand All @@ -140,7 +142,7 @@ <h5>userArn: <span class="tsd-signature-type">string</span></h5>
<h5>messagingSessionId: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span></h5>
</li>
<li>
<h5>endpointUrl: <span class="tsd-signature-type">string</span></h5>
<h5>endpointUrl: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span></h5>
</li>
<li>
<h5>chimeClient: <span class="tsd-signature-type">any</span></h5>
Expand All @@ -159,17 +161,17 @@ <h3>chime<wbr>Client</h3>
<div class="tsd-signature tsd-kind-icon">chime<wbr>Client<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/MessagingSessionConfiguration.ts#L40">src/messagingsession/MessagingSessionConfiguration.ts:40</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/MessagingSessionConfiguration.ts#L44">src/messagingsession/MessagingSessionConfiguration.ts:44</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="endpointurl" class="tsd-anchor"></a>
<h3>endpoint<wbr>Url</h3>
<div class="tsd-signature tsd-kind-icon">endpoint<wbr>Url<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<div class="tsd-signature tsd-kind-icon">endpoint<wbr>Url<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/MessagingSessionConfiguration.ts#L39">src/messagingsession/MessagingSessionConfiguration.ts:39</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/MessagingSessionConfiguration.ts#L43">src/messagingsession/MessagingSessionConfiguration.ts:43</a></li>
</ul>
</aside>
</section>
Expand All @@ -179,7 +181,7 @@ <h3>messaging<wbr>Session<wbr>Id</h3>
<div class="tsd-signature tsd-kind-icon">messaging<wbr>Session<wbr>Id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/MessagingSessionConfiguration.ts#L38">src/messagingsession/MessagingSessionConfiguration.ts:38</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/MessagingSessionConfiguration.ts#L42">src/messagingsession/MessagingSessionConfiguration.ts:42</a></li>
</ul>
</aside>
</section>
Expand Down Expand Up @@ -249,7 +251,7 @@ <h3>user<wbr>Arn</h3>
<div class="tsd-signature tsd-kind-icon">user<wbr>Arn<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/MessagingSessionConfiguration.ts#L37">src/messagingsession/MessagingSessionConfiguration.ts:37</a></li>
<li>Defined in <a href="https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsession/MessagingSessionConfiguration.ts#L41">src/messagingsession/MessagingSessionConfiguration.ts:41</a></li>
</ul>
</aside>
</section>
Expand Down
5 changes: 2 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ <h4>Getting responses from your server application</h4>
<h3>Messaging session</h3>
</a>
<p>Create a messaging session in your client application to receive messages from Amazon Chime SDK for Messaging.</p>
<pre><code class="language-js"><span class="hljs-keyword">import</span> { ChimeSDKMessagingClient, GetMessagingSessionEndpointCommand } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@aws-sdk/client-chime-sdk-messaging&#x27;</span>;
<pre><code class="language-js"><span class="hljs-keyword">import</span> { ChimeSDKMessagingClient } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@aws-sdk/client-chime-sdk-messaging&#x27;</span>;

<span class="hljs-keyword">import</span> {
ConsoleLogger,
Expand All @@ -316,11 +316,10 @@ <h3>Messaging session</h3>

<span class="hljs-comment">// You will need AWS credentials configured before calling AWS or Amazon Chime APIs.</span>
<span class="hljs-keyword">const</span> chime = <span class="hljs-keyword">new</span> ChimeSDKMessagingClient({ <span class="hljs-attr">region</span>: <span class="hljs-string">&#x27;us-east-1&#x27;</span>});
<span class="hljs-keyword">const</span> endpoint = <span class="hljs-keyword">await</span> chime.send(<span class="hljs-keyword">new</span> GetMessagingSessionEndpointCommand());

<span class="hljs-keyword">const</span> userArn = <span class="hljs-comment">/* The userArn */</span>;
<span class="hljs-keyword">const</span> sessionId = <span class="hljs-comment">/* The sessionId */</span>;
<span class="hljs-keyword">const</span> configuration = <span class="hljs-keyword">new</span> MessagingSessionConfiguration(userArn, sessionId, endpoint.Endpoint.Url, chime);
<span class="hljs-keyword">const</span> configuration = <span class="hljs-keyword">new</span> MessagingSessionConfiguration(userArn, sessionId, <span class="hljs-literal">undefined</span>, chime);
<span class="hljs-keyword">const</span> messagingSession = <span class="hljs-keyword">new</span> DefaultMessagingSession(configuration, logger);
</code></pre>
<a href="#building-and-testing" id="building-and-testing" style="color: inherit; text-decoration: none;">
Expand Down
Loading