Among Us Automute and Sharing Gameplay with Amazon Chime SDK for JavaScript

Note:
This article is also available here.(Japanese)
https://cloud.flect.co.jp/entry/2021/12/07/073749

Introduction

I used Amazon Chime SDK for JavaScript to create Among Us’ Automute function + screen delivery function. I’ve written a similar article before, and I’d like to explain some improvements about that.

By the way, as a little advertisement, we are the first Japanese company who made partner with Amazon Chime SDK. And we write a guest blog about Amazon Chime SDK on the AWS website. This article is about gaming (half as a hobby of the author), but we also have experience in developing services for business using online video. If you are interested in our services, please feel free to contact us.

Among Us and our functionality

(This section is a summary of a previous blog.)

Among Us has been explained in many places, so I won’t explain it in detail here. I’ll just give a rough outline.

Among us is a derivation of the werewolf game known as Space Werewolf. 4 or more users participate in the game and are divided into two groups: the Imposter, who plays the wolf, and the Crew, who plays the villager. The Crew does not know who is the Imposter. Crew performs tasks (mini-games) such as repairing spaceships scattered throughout the spacecraft. The Imposter, on the other hand, pretends to be the Crew, interferes with them and kills the Crew.

The Imposter wins if it reduces the number of survivors on the Crew to a certain number, and the Crew wins if it completes all tasks before the number of survivors is reduced, or if it finds the Imposter and banishes it from the spaceship. In order for the Crew to banishes the Imposter, they must gather all surviving players together for a Discussion to identify the Imposter. Players can only communicate with each other during Discussion.

Normally, discussions are held in text chat, but in order to hunt down Imposter, it is more interesting to have voice discussions (my personal opinion). In response to such requests, a group of volunteers has developed a software called AutoMuteUs that works with the game to enable voice chat only during discussions.

Also, as a matter of course, it is usually not possible to see the screens of other users. However, as shown in a TV program, it is quite fun for non-participants (spectators) and crews who have been killed to watch other users’ screens and argue with each other. For example, see this video on youtube.

Using these as a reference, I used the Amazon Chime SDK to enable voice chat during discussions, so that spectators and murdered Crew members can voice chat while watching another user’s screen, as described in my previous blog.

Improvement

As a result of publishing and operating the software in the previous blog, the following issues were raised.

  • Difficult to install and operate
  • Large amount of data transmission

Below is an explanation of each and a policy for improvement.

Ease of implementation and operation

We built all the APIs and DBs to control Amazon Chime on AWS with CDK (AWS Cloud Development Kit). However, for those who have little experience with AWS, it was difficult to understand what CDK is. Also, since we were using a number of services such as API Gateway, Lambda, DynamoDB, Cognito, etc., even though the settings were hidden by CDK, it was quite complicated to control access policies such as IAM. In addition, we had to pay for services other than Amazon Chime.

This time, we will only use AWS for Amazon Chime, and change everything else to be deployable on heroku. Heroku, like CDK, has its own set of difficulties for the beginners. However, for better or worse, heroku is not as configurable as AWS, so you hardly need to be aware of what services you are using internally. And, there is almost no need for access policy control between services, just make sure that you can access Amazon Chime from heroku. Moreover, for this use case, heroku is essentially free!

As I mentioned above, the CDK allows you to configure the AWS infrastructure in a very detailed way. For this reason, deploying to heroku is not necessarily a good idea. However, for this use case, we decided that deploying to heroku would not be a problem.
(Here is Amazon Chime’s price. )

Reduce network traffic

Among us allows up to 15 people to participate in the game, and the Amazon Chime SDK allows up to 27 video sessions (25 video sessions + 2 screen sharing sessions), so there is plenty of room for all users to share their screens. However, the amount of data transfer will naturally increase with the number of sessions. On the other hand, it is unlikely that audience will see all 15 screens at once. They may only see the screens of one or two users who he are paying attention to.

At the stage introduced in the previous blog, the screens of all users were laid out in a tiled format, but this time we will change it so that only the users we want to display can be selected and displayed on the screen. This will reduce unnecessary data transfer.

Implementation of improvement

I would like to explain the implementation points of the improvement according to the above improvement policy. For more details, please refer to the source code available in the repository described below.

Deploy API and DB to heroku

I think there are two key points to redeploying APIs and DBs that were originally running on AWS to heroku.

(1) Rebuild a fully managed service on AWS as a service on heroku
(2) Setting permissions to control Amazon Chime from heroku

(1) is as follows.

For applications using the Amazon Chime SDK, it is preferable to create a conference session on the server side to hide the AWS access key. In order to migrate to heroku, we need to create a REST API to accept session creation requests, which used to be an API Gateway + Lambda configuration. In order to migrate to heroku, we need to replace it using nodejs, for example, Express.

How to create a REST API using Express has been explained in many places, so I will not explain it here.

Also, to persist data on heroku, you need to use a postgresql add-on or something similar. This is also described in the official documentation, which can be found here.

(2) is as follows.

In order to create an Amazon Chime conference session from heroku, we need to register an access key with heroku. the Amazon Chime SDK has a lot of functionallities, and the number of policies required will increase or decrease depending on the functionality. Since we will use only basic functionality, assigning the AmazonChimeSDK to an AWS managed policy will be sufficient.

Set the access key and secret access key of the user to whom you assigned this policy to heroku’s environment variables.

heroku config:set AWS_ACCESS_KEY_ID=<ACCESS KEY>
heroku config:set AWS_SECRET_ACCESS_KEY=<SECRET ACCESS KEY>

This will allow you to control Amazon Chime from heroku.

Select the video image to display.

The Amazon Chime SDK allows you to create up to 27 video sessions. At the same time, the Amazon Chime SDK provides the ability for each client to partially reject the reception of these video data. In this article, we will allow the user to change whether or not to receive the video by clicking on each user in Among us. To change whether or not to receive video data, specify the target video tile ID, and do the following.

await meetingSession.audioVideo.pauseVideoTile(videiTileId);

or

await meetingSession.audioVideo.unpauseVideoTile(videiTileId);

This allows you to control the amount of data transfer.

Summary

This is a description of the improvements to Amongus automute made possible by the Amazon Chime SDK. This makes it much easier to deploy and more friendly to the network environment than before.

The source code for this improvement is available in the following repository. Instructions on how to deploy and use the tools can be found in the repository readme, so please give it a try. I think the afterlife is going to be pretty exciting and fun!

I am very thirsty!!

Disclaimer

Recording or capturing Amazon Chime SDK meetings with the demo in this blog may be subject to laws or regulations regarding the recording of electronic communications. It is your and your end users’ responsibility to comply with all applicable laws regarding the recordings, including properly notifying all participants in a recorded session, or communication that the session or communication is being recorded, and obtain their consent.

In no event shall we be liable for any direct, indirect, consequential, or special damages arising out of the use or inability to use the software on this blog.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store