Solution overview

更新时间:
复制 MD 格式

The integration solution without a user interface (UI) encapsulates the voice chat room APIs and provides APIs for common features, such as room management, microphone management, background music, sound effects, and audio mixing. This solution does not include UI operations, which allows for greater flexibility and custom implementations without requiring a deep understanding of the model layer logic.

Solution architecture

In the integration solution without a UI, you can integrate the component library and adjust the business implementation of the RoomService interface. This lets you use your own instant messaging (IM) service or an existing server-side interaction protocol. You can implement the components enclosed by the dashed lines in the following figure.

image

Interface descriptions

  • ARTCVoiceRoomEngine: The scenario-based API for voice chat rooms. Each API encapsulates complete business logic. The implementation of each API is detailed in the sequence diagrams that follow.

  • ARTCRoomServiceInterface: The room service interface. Each interface has a single responsibility and performs operations such as querying, updating, and sending notifications about room information and internal status. A default implementation class, ARTCRoomServiceImp, is provided. This class is implemented using services from the application's business server and the interactive messaging software development kit (SDK). The open source code for the business server is also provided for reference or custom development.

  • ARTCRtcService: An API that encapsulates the best practices of the ApsaraVideo Real-time Communication SDK. It configures various parameters and calls the corresponding ApsaraVideo Real-time Communication SDK APIs based on different scenarios, such as voice chat, KTV, and calls.

Business implementation flow

Project components

This business is implemented using the following six components.

  1. AUI: The user-facing interface.

  2. Engine: The scenario-based API for voice chat rooms. Each API encapsulates complete business logic. For more information about the APIs, see API reference.

  3. RoomService: The room service that performs operations such as querying, updating, and sending notifications about room information and internal status. A default implementation class, ARTCRoomServiceImp, is provided for the ARTCRoomServiceInterface interface. This class is implemented using services from the application's business server and the interactive messaging SDK.

  4. RTCService: Encapsulates the Alibaba Cloud ApsaraVideo Real-time Communication service. It provides operations such as joining or leaving a microphone, and starting or stopping stream ingest.

  5. AppServer provides a set of backend services based on Function Compute (FC) that are easy to deploy and customize for the AUI Kits low-code integration tool. In this project, AppServer acts as the server-side component responsible for database maintenance and IM audience group settings.

  6. Interactive Messages: The Alibaba Cloud IM Server service. It creates and maintains IM audience groups and broadcasts the status of users who join or leave a microphone.

Business flow

The voice chat room scenario is divided into the following six business flows.

  1. A user creates a room. In this flow, a room and an IM audience group are created. The creator becomes the host and automatically enters the room.

  2. A user enters a room. In this flow, the user joins a created room and the corresponding IM audience group. The user can then send text messages and listen to the real-time audio of users who are on a microphone.

  3. A user requests to join a microphone. In this flow, a user in the audience applies to join a microphone.

  4. A user leaves a microphone. In this flow, a user who is on a microphone leaves the microphone.

  5. A user leaves the room. In this flow, a user exits the room.

  6. The host dismisses the room. In this flow, the host closes the room for all users.

The following sequence diagrams provide details about these six flows. The yellow components (AUI, AppServer, and Interactive Messages) can be flexibly modified and replaced by developers. The blue components encapsulate the voice chat room scenario API service and can be used directly.

A user creates a room

This section describes the flow for creating a voice chat room. The streamer calls the createRoom interface of the AUI, which requests that the AppServer create a voice chat room. The AppServer then creates an IM audience group using the ApsaraVideo Live API and writes information about the voice chat room to the database. This information includes the IM audience group ID and the microphone status in the room. After the room is created, the user becomes the host and automatically enters the room.

image

A user enters a room

This section describes the flow for a user to enter a room. The user enters the room to retrieve detailed information, including the list of members who are on a microphone. The user also joins the IM audience group and can send messages to interact with others in the room.

image

A user requests to join a microphone

This section describes the flow for a user to request to join a microphone. When a user initiates a request, a series of interfaces are called to persist the state on the AppServer. The status is then broadcast through the IM audience group. After the user successfully joins the microphone, the RTCService pushes the real-time audio stream to the ApsaraVideo Real-time Communication service.

image

A user leaves a microphone

This section describes the flow for a user to leave a microphone. When the user leaves the microphone, a series of interfaces are called to persist the state on the AppServer. After the user successfully leaves the microphone, real-time audio streaming to the ApsaraVideo Real-time Communication service is stopped. A broadcast message about the user leaving the microphone is then sent through the IM audience group.

image

A user leaves the room

This section describes the flow for a user to leave the room. If the user is on a microphone, the A user leaves a microphone flow is executed first. Then, the user leaves the IM audience group and exits the room.

image

The host dismisses the room

This section describes the flow for a host to dismiss a room. When the host dismisses the room, the AppServer changes the room status to "Dismissed" and persists this status in the database. A message about the room's dismissal is then broadcast to the IM audience group.

image