Skip to content

Commit

Permalink
Removed action result listener usage (#1763)
Browse files Browse the repository at this point in the history
  • Loading branch information
Decoder07 authored May 8, 2024
1 parent 4f33abf commit 4dca1b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 34 deletions.
20 changes: 9 additions & 11 deletions packages/hms_room_kit/lib/src/meeting/meeting_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2415,13 +2415,19 @@ class MeetingStore extends ChangeNotifier
notifyListeners();
}

void toggleWhiteboard() {
void toggleWhiteboard() async{
if (isWhiteboardEnabled) {
if (localPeer?.peerId == whiteboardModel?.owner?.peerId) {
HMSWhiteboardController.stop();
HMSException? error = await HMSWhiteboardController.stop();
if(error != null){
log("HMSWhiteboardController.stop error: ${error.description}");
}
}
} else if (!isScreenShareOn && screenShareCount == 0) {
HMSWhiteboardController.start(title: "Whiteboard From Flutter");
HMSException? error = await HMSWhiteboardController.start(title: "Whiteboard From Flutter");
if(error != null){
log("HMSWhiteboardController.start error: ${error.description}");
}
}
notifyListeners();
}
Expand Down Expand Up @@ -2782,10 +2788,6 @@ class MeetingStore extends ChangeNotifier
break;
case HMSActionResultListenerMethod.addMultiChoicePollResponse:
break;
case HMSActionResultListenerMethod.startWhiteboard:
break;
case HMSActionResultListenerMethod.stopWhiteboard:
break;
default:
log("ActionResultListener onException-> method: ${methodType.toString()}Could not find a valid case while switching");
break;
Expand Down Expand Up @@ -2879,10 +2881,6 @@ class MeetingStore extends ChangeNotifier
break;
case HMSActionResultListenerMethod.addMultiChoicePollResponse:
break;
case HMSActionResultListenerMethod.startWhiteboard:
break;
case HMSActionResultListenerMethod.stopWhiteboard:
break;
default:
log("ActionResultListener onException-> method: ${methodType.toString()} Could not find a valid case while switching");
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,5 @@ enum HMSActionResultListenerMethod {
quickStartPoll,
addSingleChoicePollResponse,
addMultiChoicePollResponse,
startWhiteboard,
stopWhiteboard,
unknown
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,28 @@ import 'package:hmssdk_flutter/hmssdk_flutter.dart';
import 'package:hmssdk_flutter/src/service/platform_service.dart';

class HMSWhiteboardController {
static Future<void> start(
{required String title,
HMSActionResultListener? hmsActionResultListener}) async {
static Future<HMSException?> start(
{required String title}) async {
var result = await PlatformService.invokeMethod(
PlatformMethod.startWhiteboard,
arguments: {"title": title});

if (hmsActionResultListener != null) {
if (result != null) {
hmsActionResultListener.onException(
hmsException: HMSException.fromMap(result["error"]),
methodType: HMSActionResultListenerMethod.startWhiteboard);
} else {
hmsActionResultListener.onSuccess(
methodType: HMSActionResultListenerMethod.startWhiteboard);
}
if (result != null) {
return HMSException.fromMap(result["error"]);
} else {
return null;
}
}

static Future<void> stop(
{HMSActionResultListener? hmsActionResultListener}) async {
static Future<HMSException?> stop() async {
var result =
await PlatformService.invokeMethod(PlatformMethod.stopWhiteboard);

if (hmsActionResultListener != null) {
if (result != null) {
hmsActionResultListener.onException(
hmsException: HMSException.fromMap(result["error"]),
methodType: HMSActionResultListenerMethod.stopWhiteboard);
return HMSException.fromMap(result["error"]);
} else {
hmsActionResultListener.onSuccess(
methodType: HMSActionResultListenerMethod.stopWhiteboard);
return null;
}
}
}

static void addHMSWhiteboardUpdateListener(
Expand Down

0 comments on commit 4dca1b2

Please sign in to comment.