From 6aa63eb2e3aefd51ffb938ee23858aa79f204b1f Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Sun, 5 Sep 2021 11:15:56 +0800 Subject: [PATCH] Fix bugs. --- lib/controllers/ion_controller.dart | 15 ++++++++++----- lib/main.dart | 2 +- lib/pages/meeting/meeting_page.dart | 12 ++++++------ lib/pages/settings/settings_page.dart | 25 +++++++++++++------------ pubspec.yaml | 2 +- 5 files changed, 31 insertions(+), 25 deletions(-) diff --git a/lib/controllers/ion_controller.dart b/lib/controllers/ion_controller.dart index 69af506..2eeddc3 100644 --- a/lib/controllers/ion_controller.dart +++ b/lib/controllers/ion_controller.dart @@ -35,10 +35,15 @@ class IonController extends GetxController { return _prefs!; } - setup(host) { + setup( + {required String host, + required String room, + required String name}) async { _baseConnector = new IonBaseConnector(host); _biz = new IonAppBiz(_baseConnector!); _sfu = new IonSDKSFU(_baseConnector!); + _sid = room; + _name = name; } connect() async { @@ -46,12 +51,12 @@ class IonController extends GetxController { await _sfu!.connect(); } - joinBIZ(String roomID, String displayName) async { - _biz!.join(sid: roomID, uid: _uid, info: {'name': '$displayName'}); + joinBIZ() async { + _biz!.join(sid: _sid, uid: _uid, info: {'name': '$_name'}); } - joinSFU(String roomID, String displayName) async { - _sfu!.join(roomID, displayName); + joinSFU() async { + _sfu!.join(_sid, _uid); } close() async { diff --git a/lib/main.dart b/lib/main.dart index fe50c09..b417bfc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,7 +17,7 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return GetMaterialApp( debugShowCheckedModeBanner: true, - unknownRoute: GetPage(name: 'not-found', page: () => NotFound()), + unknownRoute: GetPage(name: '/not-found', page: () => NotFound()), enableLog: true, theme: mDefaultTheme, logWriterCallback: Logger.write, diff --git a/lib/pages/meeting/meeting_page.dart b/lib/pages/meeting/meeting_page.dart index 8368adf..ba07207 100644 --- a/lib/pages/meeting/meeting_page.dart +++ b/lib/pages/meeting/meeting_page.dart @@ -108,9 +108,12 @@ class MeetingController extends GetxController { //https://your-backend-address.com var host = prefs.getString('server') ?? '127.0.0.1'; host = 'http://' + host + ':5551'; + //join BIZ + name.value = prefs.getString('display_name') ?? 'Guest'; + room.value = prefs.getString('room') ?? 'room1'; //init sfu and biz clients - _ionController.setup(host); + _ionController.setup(host: host, name: name.value, room: room.value); sfu!.ontrack = (MediaStreamTrack track, RemoteStream stream) async { if (track.kind == 'video') { @@ -123,7 +126,7 @@ class MeetingController extends GetxController { if (success) { try { //join SFU - await sfu!.join(room.value, name.value); + await _ionController.joinSFU(); var resolution = prefs.getString('resolution') ?? 'hd'; var codec = prefs.getString('codec') ?? 'vp8'; @@ -188,10 +191,7 @@ class MeetingController extends GetxController { //connect to BIZ and SFU await _ionController.connect(); - //join BIZ - name.value = prefs.getString('display_name') ?? 'Guest'; - room.value = prefs.getString('room') ?? 'room1'; - _ionController.joinBIZ(room.value, name.value); + _ionController.joinBIZ(); } _removeAdapter(String mid) { diff --git a/lib/pages/settings/settings_page.dart b/lib/pages/settings/settings_page.dart index 495bb17..044b6b5 100644 --- a/lib/pages/settings/settings_page.dart +++ b/lib/pages/settings/settings_page.dart @@ -169,10 +169,11 @@ class SettingsView extends GetView { ), Padding( padding: const EdgeInsets.fromLTRB(4.0, 0.0, 4.0, 0), - child: Obx( () => _buildRowFixTitleRadio( - _codecItems, controller._codec.value, (value) { - controller._codec.value = value; - })), + child: Obx(() => _buildRowFixTitleRadio( + _codecItems, controller._codec.value, + (value) { + controller._codec.value = value; + })), ), ], ), @@ -189,10 +190,10 @@ class SettingsView extends GetView { Padding( padding: const EdgeInsets.fromLTRB(4.0, 0.0, 4.0, 0), child: Obx(() => _buildRowFixTitleRadio( - _resolutionItems, controller._resolution.value, - (value) { - controller._resolution.value = value; - })), + _resolutionItems, + controller._resolution.value, (value) { + controller._resolution.value = value; + })), ), ], ), @@ -209,10 +210,10 @@ class SettingsView extends GetView { Padding( padding: const EdgeInsets.fromLTRB(4.0, 0.0, 4.0, 0), child: Obx(() => _buildRowFixTitleRadio( - _bandwidthItems, controller._bandwidth.value, - (value) { - controller._bandwidth.value = value; - })), + _bandwidthItems, controller._bandwidth.value, + (value) { + controller._bandwidth.value = value; + })), ), ], ), diff --git a/pubspec.yaml b/pubspec.yaml index 61e1c6e..76fc61c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 - flutter_ion: ^0.5.3 + flutter_ion: ^0.5.4 shared_preferences: ^2.0.5 date_format: ^2.0.2 quiver: ^3.0.0