From dd49fd722a5dc78fd00701d8bd6f94212787dfff Mon Sep 17 00:00:00 2001 From: jingwy <86084333+jingwy@users.noreply.github.com> Date: Thu, 2 Jun 2022 15:44:04 -0700 Subject: [PATCH] Prefetch feature adoption 3.x (#2266) * Add in support for prefetch-on for websocket connection on messaging session --- CHANGELOG.md | 1 + README.md | 7 + .../messagingSession/messagingSession.html | 6 +- .../app/messagingSession/messagingSession.ts | 6 + docs/assets/js/search.json | 679 +++++++++--------- docs/classes/defaultmessagingsession.html | 12 +- .../messagingsessionconfiguration.html | 38 +- docs/enums/prefetchon.html | 158 ++++ docs/globals.html | 4 + docs/index.html | 8 + script/audit-deps | 4 +- src/index.ts | 2 + .../DefaultMessagingSession.ts | 4 + .../MessagingSessionConfiguration.ts | 8 + src/messagingsession/PrefetchOn.ts | 9 + .../DefaultMessagingSession.test.ts | 28 + 16 files changed, 622 insertions(+), 352 deletions(-) create mode 100644 docs/enums/prefetchon.html create mode 100644 src/messagingsession/PrefetchOn.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 1507166b31..00287c59e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add the reserved status code AudioDisconnectAudio. +- Add support in `MessagingSession` to allow websocket connection for messaging service to enable Prefetch feature. ### Removed diff --git a/README.md b/README.md index 17bc60101f..345a8c3302 100644 --- a/README.md +++ b/README.md @@ -250,6 +250,13 @@ const sessionId = /* The sessionId */; const configuration = new MessagingSessionConfiguration(userArn, sessionId, endpoint.Endpoint.Url, 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. +Prefetch feature will send out CHANNEL_DETAILS event upon websocket connection, which includes information about channel, +channel messages, channel memberships etc. + +```js +configuration.prefetchOn = PrefetchOn.Connect; +``` ## Building and testing diff --git a/demos/browser/app/messagingSession/messagingSession.html b/demos/browser/app/messagingSession/messagingSession.html index 52ebaf9a73..311f8c6e73 100644 --- a/demos/browser/app/messagingSession/messagingSession.html +++ b/demos/browser/app/messagingSession/messagingSession.html @@ -23,6 +23,10 @@