Example #1
0
        protected virtual ActionResult VoiceView(string id, string vEvent, string json, string sessionId)
        {
            if (string.IsNullOrEmpty(sessionId))
            {
                throw new Exception("Session ID cannot be empty or null."); // TODO: Return an error view indicating the issue.
            }
            CallFlow.CallFlow callFlow = GetCallFlow(sessionId);
            callFlow["Channel"] = "VOICE";

            callFlow.SessionId = sessionId;
            callFlow.FireEvent(vEvent, json);

            VoiceModel doc = callFlow.CurrState.DataModel;

            if (isJson(callFlow.CurrState.jsonArgs))
            {
                doc.json = callFlow.CurrState.jsonArgs;
            }
            if (doc.ViewName == "Call")
            {
                doc.nextUri = doc.nextUri + "/StateMachine";
            }
            else if (doc.ViewName == "Record")
            {
                doc.nextUri = VxmlRecordingUri;
            }
            else
            {
                doc.nextUri = VxmlUri;
            }

            SetCallFlow(callFlow, sessionId);

            return(View(doc.ViewName, doc));
        }
Example #2
0
        public virtual string StartTropo(string id, Session session)
        {
            _log.Debug("Recieved Tropo start request: ", session);
            string vEvent = "";
            string vData  = "";

            CallFlow.CallFlow callFlow = BuildCallFlow();
            if (string.IsNullOrEmpty(id))
            {
                id = "unknown";
            }
            callFlow["AppId"]       = id;
            callFlow["ANI"]         = session.from.id;
            callFlow["Channel"]     = session.from.channel;
            callFlow["InitialText"] = session.initialText;

            callFlow.FireEvent(vEvent, vData);

            VoiceModel doc = callFlow.CurrState.DataModel;

            if (isJson(callFlow.CurrState.jsonArgs))
            {
                doc.json = callFlow.CurrState.jsonArgs;
            }
            if (doc.ViewName == "Call")
            {
                doc.nextUri = doc.nextUri + "/Tropo";
            }
            else
            {
                doc.nextUri = TropoUri;
            }
            SetCallFlow(callFlow, session.id);
            string recordingUri = TropoRecordingUri + "?vm_session_id=" + session.id;
            string json         = TropoUtilities.ConvertVoiceModelToWebApi(doc, recordingUri);

            _log.Debug("Sending Tropo response:[" + json + "]");
            return(json);
        }