GetHistory 获取消息历史
()
| 276 | |
| 277 | // GetHistory 获取消息历史 |
| 278 | func (r *Room) GetHistory() []RoomMessage { |
| 279 | r.mu.RLock() |
| 280 | defer r.mu.RUnlock() |
| 281 | |
| 282 | // 返回副本 |
| 283 | history := make([]RoomMessage, len(r.history)) |
| 284 | copy(history, r.history) |
| 285 | return history |
| 286 | } |
| 287 | |
| 288 | // ClearHistory 清空消息历史 |
| 289 | func (r *Room) ClearHistory() { |