Example #1
0
        /// <summary>
        /// Retrieves the Client Session Data for the given session ID
        /// </summary>
        /// <param name="sessionId">The Id of the session to retrieve the data for</param>
        /// <returns>The Client Session Data</returns>
        public Model.ClientSessionData GetSessionData(string sessionId)
        {
            if (this.SessionDetails.ContainsKey(sessionId))
            {
                return(this.sessionDetails[sessionId]);
            }
            else if (this.securedData.ContainsKey(sessionId.Substring(0, ClientSessionStore.SessionIdSubstringLength)))
            {
                List <SecuredClientsessionData> d = this.securedData[sessionId.Substring(0, ClientSessionStore.SessionIdSubstringLength)];
                foreach (SecuredClientsessionData scsd in d)
                {
                    try
                    {
                        // SecuredClientsessionData scsd = this.securedData[sessionId.Substring(0, ClientSessionStore.SessionIdSubstringLength)];
                        string data = scsd.SecuredData;
                        UserSessionConfiguration config = this.Deserialize <UserSessionConfiguration>(MachineKeyEncryption.Decrypt(data, sessionId));
                        ClientSessionData        csd    = new ClientSessionData()
                        {
                            LastTimeUpdated = scsd.LastUpdated, UserSessionConfiguration = config
                        };

                        this.SessionDetails.AddOrUpdate(sessionId, csd, (k, v) => { return(csd); });
                        d.Remove(scsd);
                        return(this.sessionDetails[sessionId]);
                    }
                    catch (Exception)
                    {
                        // Obviously it wasn't this one
                    }
                }
            }

            return(null);
        }
Example #2
0
        /// <summary>
        /// Loads a session's data based upon the given Session ID.
        /// Websites and applications with the HttPContext.Current available can use <see cref="M:LoadSession()"/> instead
        /// </summary>
        /// <param name="sessionId">The Id of the session to load</param>
        public static void LoadSession(string sessionId)
        {
            ClientSessionData data = null;

            if ((data = WcfUserClientSession.SessionStore.GetSessionData(sessionId)) != null)
            {
                WcfUserClientSession.SetClientSession(data.UserSessionConfiguration);
            }
        }
Example #3
0
        /// <summary>
        /// Sets the client session to be a session with the given User Session Configuration
        /// </summary>
        /// <param name="config">The user session configuration for the current client session</param>
        public static void SetClientSession(UserSessionConfiguration config)
        {
            if (config == null || string.IsNullOrWhiteSpace(config.SessionId))
            {
                return;
            }

            ClientSessionData data = new ClientSessionData()
            {
                LastTimeUpdated = DateTime.Now, UserSessionConfiguration = config
            };

            WcfUserClientSession.SessionStore.StoreSession(config.SessionId, data);
            WcfUserClientSession.Current = new WcfUserClientSession(config);
        }
 void Awake()
 {
     Instance = this;
     DontDestroyOnLoad(gameObject);
 }