stopWhiteboard function

Future<HeadlessActionResult> stopWhiteboard(
  1. MediasfuParameters parameters
)

Implementation

Future<HeadlessActionResult> stopWhiteboard(
    MediasfuParameters parameters) async {
  if (!getWhiteboardState(parameters).active) {
    return const HeadlessActionResult.failure('The whiteboard is not running.');
  }
  try {
    final response = await _emitAck(
        parameters, 'stopWhiteboard', {'roomName': parameters.roomName});
    if (response['success'] != true) {
      return HeadlessActionResult.failure(response['reason']?.toString() ??
          'The whiteboard could not be stopped.');
    }
    parameters.updateWhiteboardStarted(false);
    parameters.updateWhiteboardEnded(true);
    return const HeadlessActionResult.success();
  } catch (error) {
    return HeadlessActionResult.failure(
        'The whiteboard could not be stopped: $error');
  }
}