|
@@ -111,16 +111,20 @@ final class RecordingNotifier extends AutoDisposeAsyncNotifier<RecordingState> {
|
|
|
|
|
|
|
|
LiveKitService get _liveKit => ref.read(liveKitServiceProvider);
|
|
LiveKitService get _liveKit => ref.read(liveKitServiceProvider);
|
|
|
|
|
|
|
|
- Future<({String room, String url, String token})> _getRoomInfo(String identity) async {
|
|
|
|
|
|
|
+ String? _currentRoom;
|
|
|
|
|
+
|
|
|
|
|
+ Future<({String room, String url, String token})> _getRoomInfo(String identity, {String? resumeRoom}) async {
|
|
|
final lkUrl = await ref.read(settingsServiceProvider).getLiveKitUrl();
|
|
final lkUrl = await ref.read(settingsServiceProvider).getLiveKitUrl();
|
|
|
final dispatcherUrl = await ref.read(settingsServiceProvider).getDispatcherUrl();
|
|
final dispatcherUrl = await ref.read(settingsServiceProvider).getDispatcherUrl();
|
|
|
|
|
|
|
|
if (dispatcherUrl.isNotEmpty) {
|
|
if (dispatcherUrl.isNotEmpty) {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ final body = <String, String>{'identity': identity};
|
|
|
|
|
+ if (resumeRoom != null) body['room'] = resumeRoom;
|
|
|
final resp = await http.post(
|
|
final resp = await http.post(
|
|
|
Uri.parse('$dispatcherUrl/connect'),
|
|
Uri.parse('$dispatcherUrl/connect'),
|
|
|
headers: {'Content-Type': 'application/json'},
|
|
headers: {'Content-Type': 'application/json'},
|
|
|
- body: jsonEncode({'identity': identity}),
|
|
|
|
|
|
|
+ body: jsonEncode(body),
|
|
|
).timeout(const Duration(seconds: 5));
|
|
).timeout(const Duration(seconds: 5));
|
|
|
if (resp.statusCode == 200) {
|
|
if (resp.statusCode == 200) {
|
|
|
final data = jsonDecode(resp.body) as Map<String, dynamic>;
|
|
final data = jsonDecode(resp.body) as Map<String, dynamic>;
|
|
@@ -147,6 +151,7 @@ final class RecordingNotifier extends AutoDisposeAsyncNotifier<RecordingState> {
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
final info = await _getRoomInfo(identity);
|
|
final info = await _getRoomInfo(identity);
|
|
|
|
|
+ _currentRoom = info.room;
|
|
|
try {
|
|
try {
|
|
|
await _liveKit.connect(url: info.url, room: info.room, identity: identity, token: info.token);
|
|
await _liveKit.connect(url: info.url, room: info.room, identity: identity, token: info.token);
|
|
|
} on Exception catch (e) {
|
|
} on Exception catch (e) {
|
|
@@ -237,7 +242,7 @@ final class RecordingNotifier extends AutoDisposeAsyncNotifier<RecordingState> {
|
|
|
if (state.value?.status != RecordingStatus.paused) return;
|
|
if (state.value?.status != RecordingStatus.paused) return;
|
|
|
try {
|
|
try {
|
|
|
final identity = 'user-${_uuid.v4().substring(0, 6)}';
|
|
final identity = 'user-${_uuid.v4().substring(0, 6)}';
|
|
|
- final info = await _getRoomInfo(identity);
|
|
|
|
|
|
|
+ final info = await _getRoomInfo(identity, resumeRoom: _currentRoom);
|
|
|
await _liveKit.connect(url: info.url, room: info.room, identity: identity, token: info.token);
|
|
await _liveKit.connect(url: info.url, room: info.room, identity: identity, token: info.token);
|
|
|
_updateState((s) => _startedState(s));
|
|
_updateState((s) => _startedState(s));
|
|
|
} on Exception catch (e) {
|
|
} on Exception catch (e) {
|