Ejemplo n.º 1
0
        private void SetDoulbeScreenRenderCallback(IntPtr pData)
        {
            try
            {
                AsynCallResult asynCallRulst = (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));
                Log.Logger.Debug($"SetDoulbeScreenRenderCallback回调结果{asynCallRulst.m_rc}--{asynCallRulst.m_message}");
                ReturnMessage setDoubleScreenMessage;

                if (asynCallRulst.m_rc == 0)
                {
                    setDoubleScreenMessage = ReturnMessage.GenerateData(asynCallRulst.m_message);
                }
                else
                {
                    setDoubleScreenMessage = ReturnMessage.GenerateError(asynCallRulst.m_message,
                                                                         asynCallRulst.m_rc.ToString());
                }

                SetResult("SetDoubleScreenRender", setDoubleScreenMessage);
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"SetDoulbeScreenRenderCallback回调异常:{ex.Message}");
            }
        }
Ejemplo n.º 2
0
        private void ErrorMsgReceivedCallback(IntPtr pData)
        {
            var errorMsgResult = (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));

            ReturnMessage message = ReturnMessage.GenerateError(errorMsgResult.m_message, errorMsgResult.m_rc.ToString());

            ErrorMsgReceivedEvent?.Invoke(message);
        }
Ejemplo n.º 3
0
        private async Task <ReturnMessage> Request(string requestUrl, HttpContent content = null)
        {
            using (var httpClient = new HttpClient())
            {
                var serverAddress =
                    $"http://{GlobalData.Instance.ConfigManager.ServerInfo?.ServerIp}:{GlobalData.Instance.ConfigManager.ServerInfo?.BmsServerPort}";
                //var serverAddress = "http://114.112.74.110:81";
                httpClient.BaseAddress = new Uri(serverAddress);

                HttpResponseMessage response;
                ReturnMessage       bmsMessage;

                try
                {
                    response = content == null
                        ? await httpClient.GetAsync(requestUrl)
                        : await httpClient.PostAsync(requestUrl, content);
                }
                catch (Exception ex)
                {
                    Log.Logger.Error($"Request exception:{ex}");
                    bmsMessage = ReturnMessage.GenerateError(ex.Message, "-999");
                    return(bmsMessage);
                }


                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    Log.Logger.Debug($"HttpResponseMessage Content:{result}");


                    JObject jObject = JObject.Parse(result.ToLower());
                    string  status  = jObject.SelectToken("status").ToString();
                    string  message = jObject.SelectToken("message").ToString();

                    if (status != "0")
                    {
                        bmsMessage = ReturnMessage.GenerateError(message, status);
                    }
                    else
                    {
                        bmsMessage = ReturnMessage.GenerateData(result);
                    }
                }
                else
                {
                    bmsMessage = ReturnMessage.GenerateError(response.ReasonPhrase,
                                                             response.StatusCode.ToString());
                }

                return(bmsMessage);
            }
        }
Ejemplo n.º 4
0
        private void InviteCallback(IntPtr pData)
        {
            AsynCallResult result = (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));

            ReturnMessage inviteReturnMessage;

            if (result.m_rc == 0)
            {
                inviteReturnMessage = ReturnMessage.GenerateMessage(result.m_message);
            }
            else
            {
                inviteReturnMessage = ReturnMessage.GenerateError(result.m_message, result.ToString());
            }

            SetResult("InviteParticipants", inviteReturnMessage);
        }
Ejemplo n.º 5
0
        private void StartShareDocCallback(IntPtr pData)
        {
            AsynCallResult asynCallRulst = (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));

            ReturnMessage startDocMessage;

            if (asynCallRulst.m_rc == 0)
            {
                startDocMessage = ReturnMessage.GenerateMessage(asynCallRulst.m_message);
            }
            else
            {
                startDocMessage = ReturnMessage.GenerateError(asynCallRulst.m_message, asynCallRulst.m_rc.ToString());
            }

            SetResult("StartShareDoc", startDocMessage);
        }
Ejemplo n.º 6
0
        private void ApplyToSpeakCallback(IntPtr pData)
        {
            AsynCallResult applyResult = (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));

            ReturnMessage applyMessage;

            if (applyResult.m_rc == 0)
            {
                applyMessage = ReturnMessage.GenerateMessage(applyResult.m_message);
            }
            else
            {
                applyMessage = ReturnMessage.GenerateError(applyResult.m_message, applyResult.m_rc.ToString());
            }

            SetResult("ApplyToSpeak", applyMessage);
        }
Ejemplo n.º 7
0
        private void StopLiveStreamCallback(IntPtr pData)
        {
            var stopLiveStreamResult = (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));

            ReturnMessage stopLiveMessage;

            if (stopLiveStreamResult.m_rc == 0)
            {
                stopLiveMessage = ReturnMessage.GenerateData(stopLiveStreamResult.m_message);
            }
            else
            {
                stopLiveMessage = ReturnMessage.GenerateError(stopLiveStreamResult.m_message,
                                                              stopLiveStreamResult.m_rc.ToString());
            }

            SetResult("StopLiveStream", stopLiveMessage);
        }
Ejemplo n.º 8
0
        private void SendUiMessageCallback(IntPtr pData)
        {
            var sendUiMsgResult = (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));

            ReturnMessage sendUiReturnMessage;

            if (sendUiMsgResult.m_rc == 0)
            {
                sendUiReturnMessage = ReturnMessage.GenerateMessage(sendUiMsgResult.m_message);
            }
            else
            {
                sendUiReturnMessage = ReturnMessage.GenerateError(sendUiMsgResult.m_message,
                                                                  sendUiMsgResult.m_rc.ToString());
            }

            SetResult("SendUIMessage", sendUiReturnMessage);
        }
Ejemplo n.º 9
0
        private void QueryMeetingExistCallback(IntPtr pData)
        {
            var queryMeetingExistResult =
                (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));

            ReturnMessage queryMeetingMsg;

            if (queryMeetingExistResult.m_rc == 0)
            {
                queryMeetingMsg = ReturnMessage.GenerateMessage(queryMeetingExistResult.m_message);
            }
            else
            {
                queryMeetingMsg = ReturnMessage.GenerateError(queryMeetingExistResult.m_message,
                                                              queryMeetingExistResult.m_rc.ToString());
            }

            SetResult("QueryMeetingExist", queryMeetingMsg);
        }
Ejemplo n.º 10
0
        private void SetRecordParamCallback(IntPtr pData)
        {
            var setRecordParamResult = (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));

            ReturnMessage setRecordMessage;

            if (setRecordParamResult.m_rc == 0)
            {
                setRecordMessage = ReturnMessage.GenerateData(setRecordParamResult.m_message);
            }
            else
            {
                setRecordMessage = ReturnMessage.GenerateError(setRecordParamResult.m_message,
                                                               setRecordParamResult.m_rc.ToString());
            }


            SetResult("SetRecordParameter", setRecordMessage);
        }
Ejemplo n.º 11
0
        private void OpenCameraCallback(IntPtr pData)
        {
            AsynCallResult openCameraResult = Marshal.PtrToStructure <AsynCallResult>(pData);

            ReturnMessage openCameraMessage;

            if (openCameraResult.m_rc == 0)
            {
                openCameraMessage = ReturnMessage.GenerateData(openCameraResult.m_message);
            }
            else
            {
                openCameraMessage = ReturnMessage.GenerateError(openCameraResult.m_message,
                                                                openCameraResult.m_rc.ToString());
            }


            OpenCameraEvent?.Invoke(openCameraMessage);
        }
Ejemplo n.º 12
0
        private void ExitMeetingCallback(IntPtr pData)
        {
            var exitMeetingResult = (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));

            ReturnMessage exitMessage;

            if (exitMeetingResult.m_rc == 0)
            {
                exitMessage = ReturnMessage.GenerateMessage(exitMeetingResult.m_message);
            }
            else
            {
                exitMessage = ReturnMessage.GenerateError(exitMeetingResult.m_message, exitMeetingResult.m_rc.ToString());
            }

            ExitMeetingEvent?.Invoke();

            SetResult("ExitMeeting", exitMessage);
        }
Ejemplo n.º 13
0
        private void UpdateLiveVideoStreamsCallback(IntPtr pData)
        {
            var updateLiveVideoStreamsResult =
                (AsynCallResult)Marshal.PtrToStructure(pData, typeof(AsynCallResult));


            ReturnMessage updateLiveMessage;

            if (updateLiveVideoStreamsResult.m_rc == 0)
            {
                updateLiveMessage = ReturnMessage.GenerateData(updateLiveVideoStreamsResult.m_message);
            }
            else
            {
                updateLiveMessage = ReturnMessage.GenerateError(updateLiveVideoStreamsResult.m_message,
                                                                updateLiveVideoStreamsResult.m_rc.ToString());
            }

            SetResult("UpdateLiveVideoStreams", updateLiveMessage);
        }
Ejemplo n.º 14
0
        private void StartRecordCallback(IntPtr pData)
        {
            var startRecrodResult =
                (LocalRecordResult)Marshal.PtrToStructure(pData, typeof(LocalRecordResult));

            ReturnMessage startRecordMessage;

            if (startRecrodResult.m_result.m_rc == 0)
            {
                startRecordMessage = ReturnMessage.GenerateData(startRecrodResult.m_liveId);
            }
            else
            {
                startRecordMessage = ReturnMessage.GenerateError(startRecrodResult.m_result.m_message,
                                                                 startRecrodResult.m_result.m_rc.ToString());
            }


            SetResult("StartRecord", startRecordMessage);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// api返回结果即为结果,不是标准的带reusltcode,data,message
        /// </summary>
        /// <param name="requestUrl"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        private async Task <ReturnMessage> HttpPostData(string requestUrl, HttpContent content = null, string baseUrl = "")
        {
            using (var httpClient = new HttpClient())
            {
                if (string.IsNullOrEmpty(baseUrl))
                {
                    baseUrl = $"http://{GlobalData.Instance.ConfigManager.ServerInfo.ServerIp}:{GlobalData.Instance.ConfigManager.ServerInfo.BmsServerPort}";
                }
                httpClient.BaseAddress = new Uri(baseUrl);
                HttpResponseMessage response;
                ReturnMessage       bmsMessage;
                try
                {
                    response = await httpClient.PostAsync(requestUrl, content);
                }
                catch (Exception ex)
                {
                    Log.Logger.Error($"HttpPostData exception:{ex}");

                    bmsMessage = ReturnMessage.GenerateError(ex.Message);
                    return(bmsMessage);
                }
                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    Log.Logger.Debug($"HttpResponseMessage Content:{result}");

                    bmsMessage = ReturnMessage.GenerateData(result);
                }
                else
                {
                    bmsMessage = ReturnMessage.GenerateError(response.ReasonPhrase,
                                                             response.StatusCode.ToString());
                }

                return(bmsMessage);
            }
        }
Ejemplo n.º 16
0
        private void StartCallback(IntPtr pData)
        {
            StartResult startResult = (StartResult)Marshal.PtrToStructure(pData, typeof(StartResult));

            IsServierStarted = startResult.m_result.m_rc == 0;

            ReturnMessage startReturnMessage;

            if (startResult.m_result.m_rc == 0)
            {
                CurrentAttendee.Id   = GlobalData.Instance.Classroom.SchoolRoomNum;
                CurrentAttendee.Name = GlobalData.Instance.Classroom.SchoolRoomName;
                IsServierStarted     = true;
                startReturnMessage   = ReturnMessage.GenerateMessage(startResult.m_result.m_message);
            }
            else
            {
                IsServierStarted   = false;
                startReturnMessage = ReturnMessage.GenerateError(startResult.m_result.m_message);
            }

            SetResult("Start", startReturnMessage);
        }
Ejemplo n.º 17
0
        private void CreateMeetingCallback(IntPtr pData)
        {
            CreateMeetingResult createMeetingResult =
                (CreateMeetingResult)Marshal.PtrToStructure(pData, typeof(CreateMeetingResult));

            ReturnMessage createMeetingMessage;

            if (createMeetingResult.m_result.m_rc == 0)
            {
                MainSpeaker = CurrentAttendee;

                CurrentMeetingId = createMeetingResult.m_meetingId;

                createMeetingMessage = ReturnMessage.GenerateData(createMeetingResult.m_meetingId.ToString());
            }
            else
            {
                createMeetingMessage = ReturnMessage.GenerateError(createMeetingResult.m_result.m_message,
                                                                   createMeetingResult.m_result.m_rc.ToString());
            }

            SetResult("CreateMeeting", createMeetingMessage);
        }