示例#1
0
        public ActionResult Init(string userId, string sessionId, string bufferId)
        {
            OutputBuffer buffer;

            if (OutputBuffers.TryGetValue(bufferId, out buffer))
            {
                buffer.InitOutputLogger(userId, sessionId);
            }

            return(Json(new object()));
        }
示例#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));
            }
        }