Exemplo n.º 1
0
        public void NewMsg(Object i_sender, ISMessaging.Delivery.ISMDistributer.ISMDistributerEventArgs i_args)
        {
            ISMessaging.ISMsg mMsg = null;

            lock (this)
            {
                try
                {
                    //Console.WriteLine("AudioMgr_srv.NewMsg received on TID {0}.", AppDomain.GetCurrentThreadId());

                    // Copy and release the original message (so that we don't have to call back to the remote client.)
                    switch (i_args.m_Msg.GetType().ToString())                                  // FIX - There has to be a better way to do this...
                    {
                    /////////////////////////////////////
                    // Audio in messages
                    case "ISMessaging.SpeechRec.ISMResults":
                    {
                        ISMessaging.SpeechRec.ISMResults mTmp, mClone;

                        mTmp   = (ISMessaging.SpeechRec.ISMResults)i_args.m_Msg;
                        mClone = (ISMessaging.SpeechRec.ISMResults)mTmp.Clone();
                        mMsg   = (ISMessaging.ISMsg)mClone;

                        m_aqAudioIn[mMsg.m_Dest.m_VMC.m_iKey].Push(mMsg);
                    }
                    break;

                    case "ISMessaging.SpeechRec.ISMLoadPhrases":
                    {
                        ISMessaging.SpeechRec.ISMLoadPhrases mTmp, mClone;

                        mTmp   = (ISMessaging.SpeechRec.ISMLoadPhrases)i_args.m_Msg;
                        mClone = (ISMessaging.SpeechRec.ISMLoadPhrases)mTmp.Clone();
                        mMsg   = (ISMessaging.ISMsg)mClone;

                        m_aqAudioIn[mMsg.m_Dest.m_VMC.m_iKey].Push(mMsg);
                    }
                    break;

                    case "ISMessaging.SpeechRec.ISMLoadGrammarFile":
                    {
                        ISMessaging.SpeechRec.ISMLoadGrammarFile mTmp, mClone;

                        mTmp   = (ISMessaging.SpeechRec.ISMLoadGrammarFile)i_args.m_Msg;
                        mClone = (ISMessaging.SpeechRec.ISMLoadGrammarFile)mTmp.Clone();
                        mMsg   = (ISMessaging.ISMsg)mClone;

                        m_aqAudioIn[mMsg.m_Dest.m_VMC.m_iKey].Push(mMsg);
                    }
                    break;

                    case "ISMessaging.Audio.ISMSetProperty":
                    {
                        ISMessaging.Audio.ISMSetProperty mTmp   = (ISMessaging.Audio.ISMSetProperty)i_args.m_Msg;
                        ISMessaging.Audio.ISMSetProperty mClone = (ISMessaging.Audio.ISMSetProperty)mTmp.Clone();
                        mMsg = mClone;

                        m_aqAudioIn[mMsg.m_Dest.m_VMC.m_iKey].Push(mMsg);
                    }
                    break;

                    /////////////////////////////////////
                    // Audio out messages
                    case "ISMessaging.Audio.ISMPlayPrompts":
                    {
                        ISMessaging.Audio.ISMPlayPrompts mTmp, mClone;

                        mTmp   = (ISMessaging.Audio.ISMPlayPrompts)i_args.m_Msg;
                        mClone = (ISMessaging.Audio.ISMPlayPrompts)mTmp.Clone();
                        mMsg   = (ISMessaging.ISMsg)mClone;

                        m_aqAudioOut[mMsg.m_Dest.m_VMC.m_iKey].Push(mMsg);
                    }
                    break;

                    /////////////////////////////////////
                    // Audio out messages
                    case "ISMessaging.Session.ISMTransferSession":
                    {
                        ISMessaging.Session.ISMTransferSession mTmp, mClone;

                        mTmp   = (ISMessaging.Session.ISMTransferSession)i_args.m_Msg;
                        mClone = (ISMessaging.Session.ISMTransferSession)mTmp.Clone();
                        mMsg   = (ISMessaging.ISMsg)mClone;

                        m_aqAudioOut[mMsg.m_Dest.m_VMC.m_iKey].Push(mMsg);
                    }
                    break;

                    // Other session messages (always Audio Out messages?)
                    case "ISMessaging.Session.ISMTerminateSession":
                    {
                        ISMessaging.Session.ISMTerminateSession mTmp, mClone;

                        mTmp   = (ISMessaging.Session.ISMTerminateSession)i_args.m_Msg;
                        mClone = (ISMessaging.Session.ISMTerminateSession)mTmp.Clone();
                        mMsg   = (ISMessaging.ISMsg)mClone;

                        m_aqAudioOut[mMsg.m_Dest.m_VMC.m_iKey].Push(mMsg);
                    }
                    break;

                    case "ISMessaging.Session.ISMTerminateSessionAfterPrompts":
                    {
                        ISMessaging.Session.ISMTerminateSessionAfterPrompts mTmp, mClone;

                        mTmp   = (ISMessaging.Session.ISMTerminateSessionAfterPrompts)i_args.m_Msg;
                        mClone = (ISMessaging.Session.ISMTerminateSessionAfterPrompts)mTmp.Clone();
                        mMsg   = (ISMessaging.ISMsg)mClone;

                        m_aqAudioOut[mMsg.m_Dest.m_VMC.m_iKey].Push(mMsg);
                    }
                    break;

                    case "ISMessaging.Session.ISMDialogManagerIdle":
                    {
                        ISMessaging.Session.ISMDialogManagerIdle mTmp, mClone;

                        mTmp   = (ISMessaging.Session.ISMDialogManagerIdle)i_args.m_Msg;
                        mClone = (ISMessaging.Session.ISMDialogManagerIdle)mTmp.Clone();
                        mMsg   = (ISMessaging.ISMsg)mClone;

                        m_aqAudioOut[mMsg.m_Dest.m_VMC.m_iKey].Push(mMsg);
                    }
                    break;

                    /////////////////////////////////////
                    // Unknown destination messages
                    case "ISMessaging.ISMsg":
                    {
                        //Console.Error.WriteLine("WARNING:  AudioMgr_Srv.NewMsg() - Message type was ISMsg.");
                        m_Logger.Log(Level.Warning, "AudioMgr_Srv.NewMsg() - Message type was ISMsg.");
                        mMsg = (ISMessaging.ISMsg)i_args.m_Msg.Clone();

                        // Where would this message go?
                    }
                    break;

                    default:
                    {
                        //Console.Error.WriteLine("ERROR:  AudioMgr_Srv.NewMsg() - Message type was not recognized: '{0}'.", i_args.m_Msg.GetType().ToString());
                        m_Logger.Log(Level.Exception, "AudioMgr_Srv.NewMsg() - Message type was not recognized: " + i_args.m_Msg.GetType().ToString());
                    }
                    break;
                    }                     // switch

                    // Release remote object
                    i_args = null;
                }
                catch (Exception exc)
                {
                    m_Logger.Log(Level.Exception, "AudioMgr_Srv.NewMsg() caught exception: " + exc.ToString());
                }
            }             // lock
        }
Exemplo n.º 2
0
        public void NewMsg(Object i_sender, ISMessaging.Delivery.ISMDistributer.ISMDistributerEventArgs i_args)
        {
            int iQIndex = -1;

            ISMessaging.ISMsg mMsg = null;
            bool bMsgBegin = false, bMsgDtmf = false;

            // Copy and release the original message (so that we don't have to call back to the remote client.)
            switch (i_args.m_Msg.GetType().ToString())                          // FIX - There has to be a better way to do this...
            {
            case "ISMessaging.SpeechRec.ISMResults":
            {
//					ISMessaging.SpeechRec.ISMResults	mTmp, mClone;
//
//					mTmp = (ISMessaging.SpeechRec.ISMResults)i_args.m_Msg;
//					mClone = (ISMessaging.SpeechRec.ISMResults)mTmp.Clone();
//					mMsg = (ISMessaging.ISMsg)mClone;
                mMsg = (ISMessaging.ISMsg)(((ISMessaging.SpeechRec.ISMResults)i_args.m_Msg).Clone());
            }
            break;

            case "ISMessaging.ISMsg":
            {
                mMsg = (ISMessaging.ISMsg)i_args.m_Msg.Clone();
            }
            break;

            case "ISMessaging.Session.ISMSessionBegin":
            {
                bMsgBegin = true;
                mMsg      = (ISMessaging.ISMsg)(((ISMessaging.Session.ISMSessionBegin)i_args.m_Msg).Clone());
            }
            break;

            case "ISMessaging.Session.ISMSessionEnd":
            {
                mMsg = (ISMessaging.ISMsg)(((ISMessaging.Session.ISMSessionEnd)i_args.m_Msg).Clone());
            }
            break;

            case "ISMessaging.Session.ISMTimerExpired":
            {
                mMsg = (ISMessaging.ISMsg)(((ISMessaging.Session.ISMTimerExpired)i_args.m_Msg).Clone());
            }
            break;

            case "ISMessaging.Audio.ISMDtmfComplete":
            {
                bMsgDtmf = true;
                mMsg     = (ISMessaging.ISMsg)(((ISMessaging.Audio.ISMDtmfComplete)i_args.m_Msg).Clone());
            }
            break;

            default:
            {
                mMsg = (ISMessaging.ISMsg)i_args.m_Msg.Clone();
                //Console.Error.WriteLine("ERROR:  DialogMgr_Srv.NewMsg() - Message type was not recognized: '{0}'.", i_args.m_Msg.GetType().ToString());
                m_Logger.Log(Level.Warning, "DialogMgr_Srv.NewMsg() - Message type was not recognized: " + i_args.m_Msg.GetType());
            }
            break;
            }

            // Release remote object
            i_args = null;

            // Push message onto appropriate queue
            if (mMsg != null)
            {
                iQIndex = mMsg.m_Dest.m_VMC.m_iKey;
                m_aqDMMsgs[iQIndex].Push(mMsg);

                //Console.WriteLine("DialogMgr_srv.NewMsg '{0}' received on TID {1}.", i_args.m_Msg.GetType().ToString(), AppDomain.GetCurrentThreadId());
                if (bMsgBegin)
                {
                    // Name the main thread if it hasn't been already (this is an even handler, so it may not have been)
                    if ((Thread.CurrentThread.Name == null) || (Thread.CurrentThread.Name == ""))
                    {
                        Thread.CurrentThread.Name = "DialogMgr_srvT";
                    }

                    // Set IpAddress, SessionId in Logger so all subsequent calls to Log() will be identified.  (Need-to/should do this in every thread once the ISMSessionBegin comes in.)
                    m_Logger.UpdateValue(Thread.CurrentThread.Name, LoggerCore.eRequiredParams.IpAddress.ToString(), Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(oAddr => oAddr.AddressFamily == AddressFamily.InterNetwork).ToString() ?? "");
                    m_Logger.UpdateValue(Thread.CurrentThread.Name, LoggerCore.eRequiredParams.SessionId.ToString(), mMsg.m_sSessionId);

                    m_Logger.Log(Level.Info, string.Format("[{0}]<<<DMNM ISMSessionBegin(F:'{1}', T:'{2}')>>>", iQIndex, ((ISMessaging.Session.ISMSessionBegin)mMsg).m_sFromAddr, ((ISMessaging.Session.ISMSessionBegin)mMsg).m_sToAddr));
                }
                else if (bMsgDtmf)
                {
                    m_Logger.Log(Level.Info, string.Format("[{0}]DialogMgr_srv.NewMsg DTMF: '{1}'.", iQIndex.ToString(), ((ISMessaging.Audio.ISMDtmfComplete)mMsg).m_sDtmf));
                }
                else
                {
                    m_Logger.Log(Level.Debug, string.Format("[{0}]DialogMgr_srv.NewMsg: {1}", iQIndex.ToString(), mMsg.GetType()));
                }
            }
            else
            {
                m_Logger.Log(Level.Exception, "DialogMgr_srv.NewMsg error: No message.");
            }
        }