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)); }
public void Execute(CallFlow cf, State state, Event e) { foreach (Action <CallFlow, State, Event> action in _actionList) { action(cf, state, e); } }
public static void SetCallFlow(CallFlow.CallFlow cf, string sessionId) { ObjectCache cache = MemoryCache.Default; CacheItemPolicy policy = new CacheItemPolicy(); //Expires after 5 minutes of none use. TODO: Make this configurable. policy.SlidingExpiration = new TimeSpan(0, 5, 0); cache.Set(sessionId, cf, policy); }
protected virtual CallFlow.CallFlow GetCallFlow(string sessionId) { CallFlow.CallFlow flow = SessionProvider.GetObject(sessionId) as CallFlow.CallFlow; if (flow == null) { flow = BuildCallFlow(); SetCallFlow(flow, sessionId); } return(flow); }
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); }
public State AddNestedCallFlow(CallFlow nestedCF) { this.NestedCF = nestedCF; return(this); }
public Var(CallFlow.CallFlow cf, string name, string value = "") { _cf = cf; _cf[name] = value; _name = name; }