Message replay

更新时间:
复制 MD 格式

After a live stream ends, you can load content, such as interactive messages and live comments, from the live channel to display during the replay.

Message replay API

You can use this API to load content, such as live comments, from a live stream after it has ended.

Note
  1. You do not need to join the audience group to use this API. You only need to log on.

  2. A single client can call this API up to 2 times per second. Calls that exceed this limit are rejected. Each call can return a maximum of 100 messages, and the maximum value for the PageSize parameter is 100. You can only retrieve messages of the live comment type.

  3. To ensure stream performance and stability, avoid using this API during a live stream.

// This API operation is mainly used for replaying historical messages after a live stream ends. Users can query messages without joining the group. This operation is time-consuming and is not recommended during live streaming. This API operation will be a paid feature in the future.
ImListHistoryMessageReq req = new ImListHistoryMessageReq();
req.groupId = "Group ID";
req.nextPageToken = 231231;  // If you do not pass this parameter, the first page is returned. When traversing, the server returns the token for the next page. The client should include this token when retrieving the next page.
req.type = 99999;            // Custom message type. The value must be greater than 10000.
req.sortType = ImSortType.ASC;
req.pageSize = 20;
req.beginTime = 0; // The start time of the time range to traverse. Unit: second. A value of 0 indicates the earliest time.
req.endTime = 0;   // The end time of the time range to traverse. Unit: second. A value of 0 indicates the latest time.
messageInterface.listHistoryMessage(req, new ImSdkValueCallback<ImListHistoryMessageRsp>() {
    @Override
    public void onSuccess(ImListHistoryMessageRsp rsp) {
    }
    @Override
    public void onFailure(Error error) {
    }
});