internal static void SetFlash(OutputProcessor sessionHolder, string sessionID, string messageID, string value) { SessionProvider session; if (!sessionHolder.Sessions.TryGetValue(sessionID, out session)) { session = new SessionProvider(); sessionHolder.Sessions[sessionID] = session; } session._flashFlip[messageID] = value; }
internal static void SetData(OutputProcessor sessionHolder, string sessionID, object data) { SessionProvider session; if (!sessionHolder.Sessions.TryGetValue(sessionID, out session)) { session = new SessionProvider(); sessionHolder.Sessions[sessionID] = session; } session.setData(data); }
protected T Session <T>(Func <T> dataFactory) { var data = SessionProvider.GetData <T>(Unit.Output, Client.SessionID); if (object.Equals(data, default(T))) { data = dataFactory(); if (object.Equals(data, default(T))) { throw new NotImplementedException("Unsupported Session data value"); } SessionProvider.SetData(Unit.Output, Client.SessionID, data); } return(data); }
/// <summary> /// Callback for on head completed event /// </summary> /// <param name="client">Client which head has been downloaded</param> private void _onHeadCompleted(Client client, byte[] data, int dataOffset, int dataLength) { Log.Trace("HttpServer._onHeadCompleted {0}", client); //TODO selecting processor according to session data client.SetUnit(Unit); client.Response = new Response(client); SessionProvider.PrepareSessionID(client); //resolve IP address accordingly forward headers string ipValue; var defaultIP = client.IP != null?client.IP.ToString() : "none"; client.Request.TryGetHeader(HttpRequest.ForwardedHeader, out ipValue, defaultIP); client.Request.SetHeader(HttpRequest.IPHeader, ipValue); if (client.Request.ContentLength > 0) { //Send to input processor var inputController = _inputManager.CreateController(client); if (inputController == null) { //there is no input controller for client _onContentCompleted(client); return; } client.Input = inputController; inputController.AcceptData(data, dataOffset, dataLength); if (inputController.ContinueDownloading) { _downloader.DownloadContent(client); } else { _onContentCompleted(client); } } else { //Send to response processor _onRequestCompleted(client); } }
/// <summary> /// Get flash value for given messageID. /// </summary> /// <param name="messageID">ID of flash message</param> /// <returns>Flash message if present, null otherwise</returns> public string Flash(string messageID) { return(SessionProvider.GetFlash(Client.Unit.Output, Client.SessionID, messageID)); }
/// <summary> /// Get flash value for given messageID. /// </summary> /// <param name="messageID">ID of flash message</param> /// <returns>Flash message if present, null otherwise</returns> protected string Flash(string messageID) { return(SessionProvider.GetFlash(Unit.Output, Client.SessionID, messageID)); }
/// <summary> /// Set value to given flash type. Flash is one display durability session data. /// </summary> /// <param name="messageID">ID of flash that will be set</param> /// <param name="value">Value of message that will be set</param> protected void Flash(string messageID, string value) { SessionProvider.SetFlash(Unit.Output, Client.SessionID, messageID, value); }
protected void RemoveSession <T>() { SessionProvider.RemoveData <T>(Unit.Output, Client.SessionID); }
protected T Session <T>(T data) { SessionProvider.SetData(Unit.Output, Client.SessionID, data); return(data); }
protected T Session <T>() { return(SessionProvider.GetData <T>(Unit.Output, Client.SessionID)); }
protected void InjectSession <T>(string sessionId, T data) { SessionProvider.SetData(Unit.Output, sessionId, data); }