Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // We store the game in the Session, but use a dictionary keyed by GUIDs which
            // are stored in the ViewState. This allows the same user in the same browser
            // to open multiple games in different browser tabs.

            if (Games == null)
            {
                Games = new Dictionary<string, PlayerHandler>();
            }

            if (OutputBuffers == null)
            {
                OutputBuffers = new Dictionary<string, OutputBuffer>();
            }

            if (Resources == null)
            {
                Resources = new SessionResources();
            }

            m_gameId = (string)ViewState["GameId"];
            if (m_gameId == null)
            {
                m_gameId = Guid.NewGuid().ToString();
                ViewState["GameId"] = m_gameId;
            }

            if (Page.IsPostBack)
            {
                if (Games.ContainsKey(m_gameId))
                {
                    m_player = Games[m_gameId];
                }

                if (!OutputBuffers.ContainsKey(m_gameId))
                {
                    // TO DO: Think this only ever happens while debugging?
                    return;
                }
                m_buffer = OutputBuffers[m_gameId];
            }
            else
            {
                m_buffer = new OutputBuffer(m_gameId);
                OutputBuffers.Add(m_gameId, m_buffer);
                m_buffer.AddJavaScriptToBuffer("setOutputBufferId", new StringParameter(m_gameId));
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // We store the game in the Session, but use a dictionary keyed by GUIDs which
            // are stored in the ViewState. This allows the same user in the same browser
            // to open multiple games in different browser tabs.

            if (Games == null)
            {
                Games = new Dictionary <string, PlayerHandler>();
            }

            if (OutputBuffers == null)
            {
                OutputBuffers = new Dictionary <string, OutputBuffer>();
            }

            if (Resources == null)
            {
                Resources = new SessionResources();
            }

            m_gameId = (string)ViewState["GameId"];
            if (m_gameId == null)
            {
                m_gameId            = Guid.NewGuid().ToString();
                ViewState["GameId"] = m_gameId;
            }

            if (Page.IsPostBack)
            {
                if (Games.ContainsKey(m_gameId))
                {
                    m_player = Games[m_gameId];
                }

                if (!OutputBuffers.ContainsKey(m_gameId))
                {
                    // TO DO: Think this only ever happens while debugging?
                    return;
                }
                m_buffer = OutputBuffers[m_gameId];
            }
            else
            {
                m_buffer = new OutputBuffer(m_gameId);
                OutputBuffers.Add(m_gameId, m_buffer);
                m_buffer.AddJavaScriptToBuffer("setOutputBufferId", new StringParameter(m_gameId));
            }
        }
Esempio n. 3
0
        private void RegisterExternalStylesheets()
        {
            var stylesheets = m_player.GetExternalStylesheets();

            if (stylesheets == null)
            {
                return;
            }

            foreach (var stylesheet in stylesheets)
            {
                m_buffer.AddJavaScriptToBuffer("addExternalStylesheet", new StringParameter(stylesheet));
            }
        }
Esempio n. 4
0
 void SessionTimeoutMessage()
 {
     m_buffer = new OutputBuffer(null);
     m_buffer.AddJavaScriptToBuffer("sessionTimeout");
     ClearJavaScriptBuffer();
 }
Esempio n. 5
0
 void SessionTimeoutMessage()
 {
     m_buffer = new OutputBuffer(null);
     m_buffer.AddJavaScriptToBuffer("sessionTimeout");
     ClearJavaScriptBuffer();
 }