53 lines
1.4 KiB
Dart
53 lines
1.4 KiB
Dart
import 'package:yumi/modules/room_game/data/models/room_game_models.dart';
|
|
import 'package:yumi/modules/room_game/data/room_game_api.dart';
|
|
|
|
class RoomGameRepository {
|
|
RoomGameRepository({RoomGameApi? api}) : _api = api ?? RoomGameApi();
|
|
|
|
final RoomGameApi _api;
|
|
|
|
Future<List<RoomGameShortcutModel>> fetchShortcutGames({
|
|
required String roomId,
|
|
}) {
|
|
return _api.fetchShortcutGames(roomId: roomId);
|
|
}
|
|
|
|
Future<List<RoomGameListItemModel>> fetchRoomGames({
|
|
required String roomId,
|
|
String category = '',
|
|
}) async {
|
|
final response = await _api.fetchRoomGames(roomId: roomId, category: category);
|
|
return response.items;
|
|
}
|
|
|
|
Future<BaishunRoomStateModel> fetchRoomState({required String roomId}) {
|
|
return _api.fetchRoomState(roomId: roomId);
|
|
}
|
|
|
|
Future<BaishunLaunchModel> launchBaishunGame({
|
|
required String roomId,
|
|
required String gameId,
|
|
int sceneMode = 0,
|
|
required String clientOrigin,
|
|
}) {
|
|
return _api.launchBaishunGame(
|
|
roomId: roomId,
|
|
gameId: gameId,
|
|
sceneMode: sceneMode,
|
|
clientOrigin: clientOrigin,
|
|
);
|
|
}
|
|
|
|
Future<BaishunRoomStateModel> closeBaishunGame({
|
|
required String roomId,
|
|
required String gameSessionId,
|
|
String reason = 'user_exit',
|
|
}) {
|
|
return _api.closeBaishunGame(
|
|
roomId: roomId,
|
|
gameSessionId: gameSessionId,
|
|
reason: reason,
|
|
);
|
|
}
|
|
}
|