private async Task ParticipateOrWatchAsync()
        {
            ResponseResult meetingResult = await _bmsService.GetMeetingByLessonId(CurLessonDetail.Id.ToString());


            Log.Logger.Debug(
                $"【get meetingId by lessonId result】:result={meetingResult.Status}, msg={meetingResult.Message}, data={meetingResult.Data}");

            if (HasErrorMsg(meetingResult.Status, meetingResult.Message))
            {
                return;
            }

            if (meetingResult.Data == null)
            {
                HasErrorMsg("-1", Messages.WarningNullDataFromServer);
                return;
            }

            switch (meetingResult.Data.ToString())
            {
            case "-1":
                HasErrorMsg("-1", Messages.WarningYouNeedCreateAMeeting);

                //create a meeting and update to database
                AsyncCallbackMsg createMeetingResult = await _sdkService.CreateInstantMeeting(new Participant[0]);

                Log.Logger.Debug(
                    $"【create meeting result】:result={createMeetingResult.Status}, msg={createMeetingResult.Message}");

                if (
                    !HasErrorMsg(createMeetingResult.Status.ToString(),
                                 createMeetingResult.Message))
                {
                    ResponseResult updateResult =
                        await _bmsService.UpdateMeetingId(CurLessonDetail.Id, _sdkService.MeetingId);

                    if (!HasErrorMsg(updateResult.Status, updateResult.Message))
                    {
                        await GotoMeeting(_sdkService.MeetingId);
                    }
                }

                break;

            case "0":
                //someone is creating a meeting, just wait
                HasErrorMsg("-1", Messages.WarningSomeoneIsCreatingAMeeting);

                break;

            default:
                int meetingId = int.Parse(meetingResult.Data.ToString());

                await GotoMeeting(meetingId);

                break;
            }
        }
Exemplo n.º 2
0
        private async Task ParticipateOrWatchAsync()
        {
            ResponseResult meetingResult = await _bmsService.GetMeetingByLessonId(CurLessonDetail.Id.ToString());


            Log.Logger.Debug(
                $"【get meetingId by lessonId result】:result={meetingResult.Status}, msg={meetingResult.Message}, data={meetingResult.Data}");

            if (HasErrorMsg(meetingResult.Status, meetingResult.Message))
            {
                return;
            }

            if (meetingResult.Data == null)
            {
                HasErrorMsg("-1", Messages.WarningNullDataFromServer);
                return;
            }

            switch (meetingResult.Data.ToString())
            {
            case "-1":
                HasErrorMsg("-1", Messages.WarningYouNeedCreateAMeeting);

                //create a meeting and update to database
                CreateMeetingResult createMeetingResult = await _sdkService.CreateMeeting(new ContactInfo[0], 0);

                Log.Logger.Debug(
                    $"【create meeting result】:result={createMeetingResult.m_result.m_rc}, msg={createMeetingResult.m_result.m_message}");

                switch (createMeetingResult.m_result.m_rc)
                {
                case 13:
                    createMeetingResult.m_result.m_message = Messages.WarningNoCamera;
                    break;

                case 14:
                    createMeetingResult.m_result.m_message = Messages.WarningNoMicrophone;
                    break;

                case 15:
                case -1009:
                    createMeetingResult.m_result.m_message = Messages.WarningNoSpeaker;
                    break;

                default:
                    break;
                }

                if (
                    !HasErrorMsg(createMeetingResult.m_result.m_rc.ToString(),
                                 createMeetingResult.m_result.m_message))
                {
                    ResponseResult updateResult =
                        await _bmsService.UpdateMeetingId(CurLessonDetail.Id, createMeetingResult.m_meetingId);

                    if (!HasErrorMsg(updateResult.Status, updateResult.Message))
                    {
                        await GotoMeeting(createMeetingResult.m_meetingId);
                    }
                }

                break;

            case "0":
                //someone is creating a meeting, just wait
                HasErrorMsg("-1", Messages.WarningSomeoneIsCreatingAMeeting);

                break;

            default:
                int meetingId = int.Parse(meetingResult.Data.ToString());

                await GotoMeeting(meetingId);

                break;
            }
        }