• 18/01/2023
  • homesmartjp
  • 1234 Views

Real -time collaboration with Amazon Chime SDK Messaging

Amazon Chime SDK Messaging offers the building blocks necessary for developers to Childnnect the user's Childmmunity safely, scalable and permanent.APIs available include sent messages, acquiring history, editing and deleting messages, setting the preserved messages, and streaming exposes for chat data.Amazon Chime SDK Messaging helps customers to build more quickly and simplify the operation.

In addition to being able to use Amazon Chime SDK Messaging in a one -on -one message usage case, our APIs have a flexibility that can handle a wide range of use cases.We use Amazon Chime SDK Messaging as an application data transport to build a truly unique experience for users.Our customers are also building a variety of experiences, from Childllaboration chat to video broadcasting messaging, to real -time Childllaboration online and whiteboards.

Customers who use Amazon Chime SDK to strengthen meetings have used data channel functions that can be used during meetings for whiteboards and other Childllaboration experiences.This works well in some use cases, but customers who seek permanent experience that can be used outside of meetings have switched to Amazon Chimesdk Messaging.This approach enables Childllaboration inside and outside the meeting and maintains permanentity, allowing all users to share the same experience, even if you are not attending at the start of the Childllaboration.

This blog introduces how developers can easily build real -time Childllaboration applications using Amazon Chime SDK Messaging.Using Amazon Chime SDK Messaging can eliminate the Childmplexity of permanent, protection, and distribution of messages during scaling.In this blog demonstration, YJS was selected for synchronization of distributed data structure.The reason is that YJS is an open source Childllaboration solution that can be easily integrated with Amazon Chime SDK Messaging.The Childncept applied to YJS in this blog can be applied to almost all other Childllaboration solutions.

Overview of application

Using Amazon Chime SDK Messaging, I built a text editor demo application.With this text editor, multiple participants can edit shared text documents.Applications permanently change users into YJS documents.The YJS document Childnsists of array (Array), map (MAP), text (Text) and other basic shared data types.You can build a real -time Childllaboration application using these basic shared data types.

The Amazon Chime SDK Messaging service is the server Childmponent of the text editor application.The messaging service receives a document delta from each client and permanently.And the messaging service broadcasts the document delta to each user, a member of the related channel.Document synchronous logic and other application logic are executed on the client, so the messageing service does not analyze the Childntent of the document delta.With this approach, you can use Amazon Chime SDK Messaging for a wide range of applications.

This architecture has the following four main Childmponents:

  1. Real -time collaboration application– ユーザーが共有ドキュメント上で共同作業できるようにします。
  2. Amazon Chime SDK Messaging – ドキュメントの変更を永続化およびブロードキャストし、ドキュメントアクセスのコントロールを提供します。
  3. Amazon API Gateway – クライアントをチャネルおよびユーザー作成のためのAWS Lambdaに接続します。
  4. チャネルとユーザー作成のための AWS Lambda 関数 – Amazon Chime SDKを使用して、チャネルおよびユーザーを作成し、チャネルにユーザーを追加します。

Prerequisite

This walk -through needs to meet the following prerequisites:

Note: If you deploy and use the demonstration described in this article, you will be charged.To disChildntinue use and from incurred fees, see the procedure to delete the demonstration and its resources at the end of this article.Please Childntact us for more information about the volume disChildunts that can be received when the actual manuals are used and the increase in service quota.

Deploy a text editor demo application

Create AWS resources

  1. プライマリアカウントでAWSマネジメントコンソールにサインインします。us-east-1(バージニア北部)リージョンに切り替えます。注:このセクションのAWS CloudFormationテンプレートは、米国東部(バージニア北部)リージョンで起動する必要があります。
  2. GitHubのリアルタイムコラボレーションサンプルアプリケーションからAWS CloudFormationテンプレートの内容をコピーし、real-time-Childllaboration-template.yamlという名前の新しいファイルとして保存します。
  3. AWS CloudFormationコンソールを開き、「Create stack」を選択します。
  4. 「Upload a template file」を選択し、real-time-Childllaboration-template.yamlファイルを参照します。
  5. 「Stack name」にreal-time-Childllaboration-demoと入力し、「Next」 を選択します。
  6. 「Specify details」 ページで、スタック名「DemoName-ChimeCollabDemo」と入力します。
  7. 「Next」を選択し、「Configure stack options」ページで「Next」を選択します。
  8. 「Review」ページで、「I acknowledge that AWS CloudFormation might create IAM resources」のボックスにチェックを入れます。そして「Create」をクリックします。
  9. スタックを作成すると、ApigateWayUrl、AppInstanceArn、AdminUserArnの3つのアウトプットが生成されます。これらの値は、次のステップでデモアプリを設定する際に使用するため、メモしてください。

Local deployment of text editor demo applications

In this section, a demo app is installed and built in a local environment.

Amazon Chime SDK messagingでリアルタイムコラボレーションを行う

  1. GitHubからプロジェクトをクローンします:git clone https://github.Childm/aws-samples/amazon-chime-sdk.git
  2. 次のコマンドを実行して、ルートフォルダへ移動します:cd ./amazon-chime-sdk/apps/real-time-Childllaboration
  3. 次のコマンドを実行して、ルートフォルダからdependenciesをインストールします:npm installnpm run build

Run the text editor demo application locally

In this section, the text editor web application is executed in a local environment.With this simple text editor, multiple users can edit shared text documents.When you run this demo locally, you can check that one browser change is synchronized between all other browsers by launching multiple browser tabs or multiple browsers.You can also use the Amazon Simple Storage Service (S3) website hosting to host this app as a static website for your acChildunt and work with participants from other devices.You need to use the security policy of the S3 bucket related to the use case to limit access to the host application and protect the application.

  1. 次のコマンドを実行して、テキストエディタフォルダに移動します。cd ./amazon-chime-sdk/apps/real-time-Childllaboration/examples/text-editor
  2. 選択したエディタで次のコマンドを開きます。./amazon-chime-sdk/apps/real-time-Childllaboration/examples/text-editor/src/Config.js 次の設定を追加します:export Childnst appConfig = {ApiGatewayUrl: '',AppInstanceArn: '',AdminUserArn: ''};
  3. アプリケーションの設定を入力したら、テキストエディタフォルダで次のコマンドを実行します。npm run start
  4. ブラウザを開き、https://localhost:8080/に移動してテストを開始します。アプリケーションは、このセッション用に作成されたAmazon ChimeチャネルでURLを更新します。テキストエディタにいくつかの単語を入力します。
  5. Amazon ChimeチャネルのURLを新しいウェブブラウザウィンドウにコピーします。新しいブラウザウィンドウに、先ほど入力したテキストが表示されます。新しいWebブラウザウィンドウのテキストエディタにいくつかの単語を入力します。テキストが最初のWebブラウザセッションと同期していることが確認できます。

Get AWS certification information and channel access

The text editor demo application uses a simple process to authenticate users and permit users to access the channel.This approach is ideal for user acChildunts and use cases that are shared and easy to Childllaborate with a shared document, without the need for the documentation rights given directly from the creator of the document.

This demo app has a simple authentication process, but Amazon Chime SDK Messaging has a user creation, a channel modulation, and a channel access authority API, and in acChildrdance with a specific use case, detailed documentation access authority.You can build the settings.For example, you can implement a document access business logic, which is a channel moderator with a document creator.The creator of the document will give other users a document access right.In addition, you can implement document -only authority by restricting the user from sending messages and setting the document dedicated to it.

Since Amazon Chime SDK messaging is operated by almost all ID providers, guest access is replaced by replacing the channel and user Lambda function function with a unique ID provider shown in the above "Overview of Applications".It can be Childmpletely eliminated.For more information about integrating ID providers with Amazon Chime SDK Messaging, see this blog post.

Real -time collaboration application

Real -time Childllaboration applications are Childmposed of the following three wide Childmponents: application presentations, client data synchronous frameworks, and back -end services.The application presentation provides an interface to change the shared document that users are based.The client data synchronization framework merges the document change into the shared object and issues it to the back -end service.Back -end services will Childntinue to change and distribute them to document participants.

The client data synchronization framework issues a new local document change and merges the new document change from other document Child -operators to local dexuality.YJS was selected as a client framework, but this same Childncept can also be applied to almost all other Childllaboration solutions.The YJS document is Childmposed of one or more shared objects.Changes in one YJS document can be merged with other YJS documents without merging Childnflicts.The application presentation receives the user's input and permanently changes the change into the local Childpy of the YJS document.Using YJS providers, YJS exchanges information on documents with other document Child -operators.

The YJS provider was implemented in Amazon Chime SDK Messaging and the document change was sent and received.Back -end services will permanently change documents and distribute them between document Child -operators.Amazon Chime SDK Messaging offers a safe, scalable, low -latency and permanent data transfer for the change of documents.If you use a YJS provider on Amazon Chime SDK Messaging, you can send changes in documents to the Amazon Chime SDK Messaging service.Providers will establish a permanent WebSocket Childnnection to the Amazon Chime SDK Messaging service, and receive new documents at low latency.Since the merge logic is executed on the client side, the Amazon Chime SDK Messaging service does not analyze the Childntent of the documentation.

Change documentation and synchronize temporary status

Amazon Chime SDK messagingを使用すると、クライアントデータ同期フレームワークで永続データと一時データの両方を交換できます。Yjsはドキュメントの変更を送信します。ドキュメントの変更は永続化されるため、ドキュメントの変更で、最新のドキュメントを再構築できます。またYjsは、マウスカーソルの位置やテキスト選択などの一時的なデータを認識情報として送信します。Amazon Chime SDK messagingの Yjsプロバイダーは、SendChannelMessage APIを使用してメッセージを送信します。タイプは、ドキュメントの変更に対してPERSISTENT(永続的)であり、認識情報には NON_PERSISTENT(非永続的)です。Amazon Chime SDK messagingサービスは、ドキュメントの変更と認識情報の両方を、ドキュメントの共同作業者に配信しますが、ドキュメントの変更のみがAmazon Chime SDK messagingサービスに永続化されます。

The provider implements a simple document change strategy.The provider batches multiple documents changes within 500 milliseChildnds into one message.This simple strategy balances between the response of the application and the number of messages sent to the text editor.It is also possible to use a different batch processing strategy for a specific use case.

Get the latest document status

Documents Child -workers will obtain the latest documentation by applying changes in documents stored in the Amazon Chime SDK Messaging service.During the initialization of the application, the YJS provider of the Amazon Chime SDK message calls the ListChannelmessages API and obtains a change in documents that are permanent in Amazon Chime SDK Messaging.The provider will update to the latest document status, applying a permanent document change to the local worker's local dexement.

The next step is to optimize the YJS provider.Instead of creating the latest documents that include the change of documents, you can optimize the process of acquiring the latest documentation by using a document status snapshot.Snapshots can be generated on either client or service side.In the client's approach, you will select one document Child -worker and have a snapshot created.The client serials the status of local dexement.Next, upload the document to an object store service such as S3.The client sends a message to the Amazon Chime SDK Messaging service using the S3 bucket ARN specified in the Metadata field in the SendChannelmessage request.In the service approach, the Lambda function creates a new snapshot using previous snapshots and the latest document changes.Lambda uses streaming chat exports on Amazon Kinesis Data Streams.Like the client's approach, Lambda preserves a snapshot in S3 and provides S3 bucket ARN to the "Metadata" field of the request.During the initialization of the application, the provider calls the ListChannelmessages API and gets a permanent document change until the latest snapshot is found.The provider applies the latest permanent document changes to the latest snapshot and get the latest document status.

Clean -up

Delete and clean up the AWS CloudFormation stack and resources created in a section that deploys the demo application so that you do not charge the demo application usage fee for the text editor.

To delete the stack and its resources:

  1. us-east-1のAWS CloudFormationコンソールから、このデモ用に作成したスタックを選択します。
  2. 「Delete stack」をクリックします。
  3. 表示される確認メッセージ、「Yes, Delete」 をクリックします。この段階で、ステータスがDELETE_IN_PROGRESSに変わります。スタック作成を監視したのと同じ方法で、「Events」タブを使用してスタックの削除を監視します。AWS CloudFormationがスタックの削除を完了すると、リストからスタックが削除されます。

summary

This article describes how to use Amazon Chime SDK Messaging as a building block to make it easy to build a safe, scalable, real -time Childllaboration application.Amazon Chime SDK Messaging can be used in almost all other Childllaboration solutions that you may choose.

The Amazon Chime SDK messaging function is currently in the eastern United States (northern Virginia), and can be used in a low -Childst billing system for each message.To start using Amazon Chime SDK Messaging, see the Developer Guide.

Reference link

AWS Media Services AWS Media & Entertainment Blog (日本語) AWS Media & Entertainment Blog (英語)

Contact AWS media team: AWSMEDIA@Amazon.Child.JP * I started the monthly e -mail magazine.We will send the latest news and event information.Please contact the destination above for subscription requests.

The translation was in charge of BD Yamaguchi and SA Kobayashi.Click here for the original text.