joinMeeting method

Joins a meeting based on the MeetHourMeetingOptions passed in. A MeetHourMeetingListener can be attached to this meeting that will automatically be removed when the meeting has ended

Implementation

@override
Future<MeetHourMeetingResponse> joinMeeting(MeetHourMeetingOptions options,
    {MeetHourMeetingListener? listener,
    Map<RoomNameConstraintType, RoomNameConstraint>?
        roomNameConstraints}) async {
  // encode `options` Map to Json to avoid error
  // in interoperability conversions
  String webOptions = jsonEncode(options.webOptions);
  String serverURL = options.serverURL ?? "meethour.io";
  serverURL = serverURL.replaceAll(cleanDomain, "");
  api = meethour.MeetHourAPI(serverURL, webOptions);

  // setup listeners
  if (listener != null) {
    api?.on("videoConferenceJoined", allowInterop((dynamic _message) {
      // Mapping object according with meethour external api source code
      Map<String, dynamic> message = {
        "displayName": _message.displayName,
        "roomName": _message.roomName
      };
      listener.onConferenceJoined?.call(message);
    }));
    api?.on("videoConferenceLeft", allowInterop((dynamic _message) {
      // Mapping object according with meethour external api source code
      Map<String, dynamic> message = {"roomName": _message.roomName};
      listener.onConferenceTerminated?.call(message);
    }));
    api?.on("feedbackSubmitted", allowInterop((dynamic message) {
      debugPrint("feedbackSubmitted message: $message");
      listener.onError?.call(message);
    }));

    // NOTE: `onConferenceWillJoin` is not supported or nof found event in web

    // add geeric listener
    _addGenericListeners(listener);

    // force to dispose view when close meeting
    // this is needed to allow create another room in
    // the same view without reload it
    api?.on("readyToClose", allowInterop((dynamic message) {
      api?.dispose();
    }));
  }

  return MeetHourMeetingResponse(isSuccess: true);
}