void NMonCore_HeadReceived(object s, SNM_RESPONSE head)
 {
     try
     {
         //收到头信息,向客户端通知头信息
         var monObj = s as MonitorObject;
         if (monObj == null)
         {
             OnDebug(LogMode.Error, string.Format("MonitorObject is null"));
             return;
         }
         NotifyMessage notMessage = new NotifyMessage();
         notMessage.SessionID = SessionID;
         notMessage.Command   = (int)Service10Command.NotNMonHeadReceived;
         notMessage.ListData.Add(monObj.MonID);
         byte[] data = Converter.Struct2Bytes(head);
         string str  = Converter.Byte2Hex(data);
         notMessage.ListData.Add(str);
         SendMessage(notMessage);
     }
     catch (Exception ex)
     {
         OnDebug(LogMode.Error, string.Format("DealNMonHead fail.\t{0}", ex.Message));
     }
 }
Exemple #2
0
        void Core_HeadReceived(object user, SNM_RESPONSE head)
        {
            SubDebug(string.Format("[VLNMon4Net]\t{0}\tVoice head received,voice format:{1}\tchannel:{2}", user, (EVLVoiceFormat)head.format, head.channel));
            //to set audio format
            EVLVoiceFormat format = (EVLVoiceFormat)head.format;

            Dispatcher.Invoke(new Action(() =>
            {
                if (RbDiretX.IsChecked == true)
                {
                    mUseDxPlayer     = true;
                    IntPtr intPtr    = (new WindowInteropHelper(this)).Handle;
                    mDxPlayer        = new DirectXPlayer(intPtr);
                    mDxPlayer.Debug += I_DXPlayer_Debug;
                    //I_DXPlayer.Prepare(format);
                    SubDebug(string.Format("Use DirectX player"));
                }
                else
                {
                    mUseDxPlayer = false;
                }
                if (RbVLNMon.IsChecked == true)
                {
                    mUseVLNMonPlayer = true;
                    mVLNMonCores[(string)user].IsPlayWave = true;
                    SubDebug(string.Format("Use VLNMon player"));
                }
                else
                {
                    mUseVLNMonPlayer = false;
                    mVLNMonCores[(string)user].IsPlayWave = false;
                }
                if (RbNAudio.IsChecked == true)
                {
                    mUseNAudioPlayer     = true;
                    mNAudioPlayer        = new NAudioPlayer();
                    mNAudioPlayer.Debug += I_NAudioPlayer_Debug;
                    mNAudioPlayer.Prepare(format);
                    SubDebug(string.Format("Use NAudio player"));
                }
                else
                {
                    mUseNAudioPlayer = false;
                }

                //if ((string)user == "VLNMon1")
                //{
                //    if (I_VLNMonCores["VLNMon0"] != null)
                //    {
                //        I_VLNMonCores["VLNMon0"].ReceiveHead(head);
                //    }
                //}
            }));
        }
Exemple #3
0
 private void DealNMonHeadMessage(NotifyMessage notMessage)
 {
     try
     {
         if (notMessage.ListData == null || notMessage.ListData.Count < 2)
         {
             AppendMessage(string.Format("NotifyMessage param count invalid."));
             return;
         }
         string strMonID = notMessage.ListData[0];
         string strHead  = notMessage.ListData[1];
         if (mNMonItem == null)
         {
             return;
         }
         if (mNMonItem.MonID != strMonID)
         {
             return;
         }
         MonitorObject monObj = mNMonItem.MonObject;
         if (monObj == null)
         {
             return;
         }
         byte[]       data = Converter.Hex2Byte(strHead);
         SNM_RESPONSE head = (SNM_RESPONSE)Converter.Bytes2Struct(data, typeof(SNM_RESPONSE));
         if (mNMonCore != null)
         {
             mNMonCore.StopMon();
             mNMonCore = null;
         }
         mNMonCore = new NMonCore(monObj);
         mNMonCore.IsConnectServer = false;
         mNMonCore.IsDecodeData    = false;
         mNMonCore.Debug          += (s, msg) => AppendMessage(string.Format("NMonCore:{0}", msg));
         mNMonCore.ReceiveHead(head);
     }
     catch (Exception ex)
     {
         AppendMessage(ex.Message);
     }
 }
Exemple #4
0
 private void DealNMonHeadMessage(NotifyMessage notMessage)
 {
     try
     {
         if (notMessage.ListData == null || notMessage.ListData.Count < 2)
         {
             CurrentApp.WriteLog("NMonHeadMessage", string.Format("ListData count invalid"));
             return;
         }
         string strMonID = notMessage.ListData[0];
         string strHead  = notMessage.ListData[1];
         if (strMonID == mMonitorObject.MonID)
         {
             MonitorObject monObj = mMonitorObject;
             byte[]        data   = Converter.Hex2Byte(strHead);
             SNM_RESPONSE  head   = (SNM_RESPONSE)Converter.Bytes2Struct(data, typeof(SNM_RESPONSE));
             if (mNMonCore != null)
             {
                 mNMonCore.StopMon();
                 mNMonCore = null;
             }
             mMonitorItem.VoiceFormat   = head.format;
             mMonitorItem.TimeDeviation = mTimeDeviation;
             mMonitorItem.UpdateState();
             mNMonCore = new NMonCore(monObj);
             mNMonCore.IsConnectServer = false;
             mNMonCore.IsDecodeData    = false;
             mNMonCore.Debug          += (s, msg) =>
             {
                 CurrentApp.WriteLog("NMonCore", msg);
             };
             mNMonCore.ReceiveHead(head);
         }
     }
     catch (Exception ex)
     {
         CurrentApp.WriteLog("NMonHeadMessage", string.Format("Fail.\t{0}", ex.Message));
     }
 }