zhibo/android-app/后端接口TODO清单-直播间弹幕.md

72 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 后端接口 TODO 清单 - 直播间弹幕模块
## 1. 发送直播间弹幕消息
**文件**: `RoomDetailActivity.java`
**接口路径**: `POST /api/rooms/{roomId}/messages`
**请求参数**:
```json
{
"roomId": "string",
"message": "string",
"userId": "string"
}
```
**返回数据**:
```json
{
"code": 200,
"data": {
"messageId": "string",
"userId": "string",
"username": "string",
"avatarUrl": "string",
"message": "string",
"timestamp": "number"
}
}
```
## 2. 获取历史弹幕消息
**文件**: `RoomDetailActivity.java`
**接口路径**: `GET /api/rooms/{roomId}/messages`
**请求参数**:
- roomId: 房间ID路径参数
- limit (可选): 获取最近N条消息默认50
**返回数据**:
```json
{
"code": 200,
"data": [
{
"messageId": "string",
"userId": "string",
"username": "string",
"avatarUrl": "string",
"message": "string",
"timestamp": "number"
}
]
}
```
## 3. 接收实时弹幕消息WebSocket
**文件**: `RoomDetailActivity.java`
**WebSocket 连接**: `ws://api.example.com/rooms/{roomId}/chat`
**接收消息格式**:
```json
{
"type": "message",
"data": {
"messageId": "string",
"userId": "string",
"username": "string",
"avatarUrl": "string",
"message": "string",
"timestamp": "number"
}
}
```
**备选方案**: 轮询获取新消息
- 接口路径: `GET /api/rooms/{roomId}/messages?lastMessageId={lastId}`
- 每3-5秒轮询一次获取lastMessageId之后的新消息