Build a UGC Live Streaming App with Amazon IVS: Inviting Chat Users to Join a Stream (Lesson 8.2)
Welcome to Lesson 8.2 in this series where we're looking at building a web based user-generated content live streaming application with Amazon IVS. This entire series is available in video format on the AWS Developers YouTube channel and all of the code related to the sample application used in this series can be viewed on GitHub. Refer to the links at the end of the post for more information.
Todd Sharp
Amazon Employee
Published Jan 3, 2024
In lessons 4.3 and 4.4, we learned how users can invite other users to join them in a low-latency or real-time live stream. To invite other users to join them, StreamCat uses Amazon IVS chat to send invites to viewers. In this lesson, we'll learn how this works.
As mentioned in lesson 8.1, the broadcaster of a live stream is presented an 'admin' menu next to each chat message that contains actions that can be taken by the broadcaster. This lets a broadcaster delete a message, disconnect a user, and invite a user to join them during a live stream.
The 'Invite to Stream' action invokes a function called
inviteUserToStage()
. As we learned in earlier lessons, each user in a real-time stream needs a stage participant token. The
/api/multihost/invite
endpoint handles generating a token. It also sends a message to that user via the Amazon IVS chat room to notify them that they have been invited to join the stream.The chat event is sent via the
sendChatEvent()
method of the ChatRoomService
.This sends a custom event called
StreamCat:MultihostInvite
to all users who are connected to the chat room. The chat room listens for this event, and displays a toast notification to the intended user.And the toast notification contains a link that the invited user can click to join the stream.
Since the user has a valid stage participant token, they are granted access to join the live stream when they click on the link.
In this lesson, we learned how the StreamCat application allows broadcasters to invite chat users to join a live stream. In the next lesson, we'll look at retrieving and displaying viewer counts for a live stream.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.