Exemplo n.º 1
0
        public override FrameSession Add(FrameSession session)
        {
            //lock (Sessions)
            // If thread safety is the issue here, ConcurrentDictionary will work better
            Sessions.TryAdd(session.Id, session);

            return(session);
        }
Exemplo n.º 2
0
        public ActionResult Screen()
        {
            FrameSession session  = CurrentFrameSession;
            String       screenId = Request["s"];
            Screen       screen   = (Screen)session.Find(screenId);

            return(View(screen.View, screen));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
 public abstract FrameSession Add(FrameSession session);
Exemplo n.º 5
0
 public FrameRequest(FrameSession session, FrameController controller)
 {
     Session    = session;
     Controller = controller;
     Response   = new FrameResponse(this);
 }