Esempio n. 1
0
        public JsonResult Event()
        {
            FrameSession session = CurrentFrameSession;

            if (session == null)
            {
                throw new Exception("No session found");
            }

            FrameRequest request = new FrameRequest(session, this);

            foreach (String key in Request.Form.AllKeys)
            {
                String value = Request[key];
                request.Vars.Add(key, value);
                if (key.StartsWith("frame-input-"))
                {
                    Input input = (Input)session.Find(key.Substring(12));
                    if (input != null)
                    {
                        input.ValueFromClient(value);
                    }
                }
            }

            //pause this thread?
            //respond on the current thread with a flag on how quickly to return.  or does it just return right away anyway, long polling?

            FrameRequest.Current = request;

            Act target = (Act)session.Find(Request["path"]);

            target.Handler();
            // this would be easier if we just utilized the default Json serializer, no?
            // just make an anon type and serialize
            IList <object> result = new List <object>();

            // lock (request.Response.Updates) -- changed this to concurrentbag
            request.Response.ApplyChanges();
            foreach (ResponseUpdate update in request.Response.Updates)
            {
                result.Add(update.Render());
            }
            // this may be expensive
            Interlocked.Exchange(ref request.Response.Updates, new ConcurrentBag <ResponseUpdate>());

            return(Json(result));
        }
Esempio n. 2
0
 public FrameResponse(FrameRequest request)
 {
     Request = request;
 }